SlideShare ist ein Scribd-Unternehmen logo
1 von 3
Downloaden Sie, um offline zu lesen
Please code this in C++ and utilize only the codes listed below. I need help on coding both
ExtendedAVLTree.h and ExtendedAVLNode.h. I'm especially confused about
ExtendedAVLTree.h since from what I understand, we are supposed to override InsertNode
and DeleteNode in the ExtendedAVLTree.h file. Please take the time to look at this carefully.
Thank you
main.cpp
AVLNode.h
AVLTree.h
BinarySearchTree.h
BSTNode.h
BSTNodeVector.h
BSTNodeVectorVisitor.h
ExtendedAVLNode.h
#ifndef EXTENDEDAVLNODE_H
#define EXTENDEDAVLNODE_H
#include "AVLNode.h"
class ExtendedAVLNode : public AVLNode {
private:
int subtreeKeyCount;
public:
ExtendedAVLNode(int nodeKey) : AVLNode(nodeKey) {
subtreeKeyCount = 1;
}
virtual int GetSubtreeKeyCount() override {
return subtreeKeyCount;
}
// Your code here
virtual void UpdateSubtreeKeyCount(BSTNode* node)
{
int count = 1;
if (GetLeft() != NULL) {
count += ((ExtendedAVLNode*) GetLeft())->GetSubtreeKeyCount();
}
if (GetRight() != NULL) {
count += ((ExtendedAVLNode*) GetRight())->GetSubtreeKeyCount();
}
subtreeKeyCount = count;
}
};
#endif
ExtendedAVLTree.h
#ifndef EXTENDEDAVLTREE_H
#define EXTENDEDAVLTREE_H
#include "AVLTree.h"
#include "ExtendedAVLNode.h"
class ExtendedAVLTree : public AVLTree {
protected:
// Each node in an ExtendedAVLTree is an ExtendedAVLNode
virtual BSTNode* MakeNewNode(int key) override {
return new ExtendedAVLNode(key);
}
// Your code here
public:
virtual int GetNthKey(int n) override {
// Your code here (remove placeholder line below)
return 0;
}
};
#endif
8.11 LAB: AVL tree Nth largest operation Step 1: Inspect the BSTNode.h and BinarySearchTree.h
files Inspect the BSTNode class declaration for a binary search tree node in BSTNode h. Access
BSTNode h by clicking on the orange arrow next to main, cpp at the top of the coding window. The
BSTNode class has private member variables for the key, parent pointer, left child pointer. and
right child pointer. Accessor functions exist for each. Inspect the BinarySearchTree class
declaration for a binary search tree node in BinarySearchTree.h. The GetNthKey0 function is the
only pure virtual function that exists. Step 2: Inspect other files related to the inheritance hierarchy
Classes AVLNode and AVLTree inherit from BSTNode and BinarySearchTree, respectively. Each
class is implemented in a read only header file. Classes ExtendedAVLNode and
ExtendedAVLTree are declared, but implementations are incomplete. Both classes must be
implemented in this lab. Read only, completed class implementation Incomplete class
implementation Step 3: Understand the purpose of the subtreeKeyCount variable The
ExtendedAVLNode class inherits from AVLNode and adds one integer member variable,
subtreeKeyCount. Each node's subtree key count is the number of keys in the subtree rooted at
that node. Ex. lunt ExtendedAVLNode's constructor and GetSubtreeKeyCount() member functions
are already implemented and should not be changed Additional member functions are needed to
ensure that subtreekeycount remains accurate Step 4: Implement ExtendedAVLTree and
ExtendedAVLNode Each node in an ExtendedAVLTree must have a correct subtreekeyCount
after an insertion or removal operation. Determine which member functions in AVLTree and
AVLNode must be overridden in ExtendedAVLTree and ExtendedAVLNode to keep each node's
subtreeKeyCount. correct. New functions can be added along with overridden functions, if desired.
Hint Consider an UpdateSubtreekeyCount O member function for the ExtendedAVLNode class.
The function requires each child node's subtreekeycount to be correct, and updates the node's
subtreekeyCount appropriately. Overridden functions in both ExtendedAVLNode and
ExtendedAVLTree can call a node's UpdateSubtreeKeyCount() function as needed Once
determinations are made, complete the implementation of both the ExtendediALTree and
ExtendedAVLNode classes. Do not implement ExtendedAVLTree's GetNthKeyO in this step.
GetNthKeyO requires correct subtree counts at each node Step 5: Run tests in develop mode and
submit mode TreeTestCommand is an abstract base class defined in TreeCommands.h. A
TreeTestCommand object is an executable command that operates on a binary search tree.
Classes inheriting from TreeTestCommand are also declared in TreeCommands.h -
TreeinsertCommand inserts keys into the tree - TreeRemoveCommand removes keys from the
tree - TreeverifykeysCommand verifies the tree's keys using an inorder traversal -
TreeverifysubtreeCountscommand verifies that each node in the tree has the expected subtree
key count - TreeGetNthCommand verifies that GetNithkey(0 returns an expected value Code in
main.opp contains three automated test cases. Each test executes a vector of TreeTestCommand
objects in sequence. The third test includes TreeGetNthcommands and will not pass until the
completion of Step 6. The first two tests should pass after completion of step4. Before proceeding
to Step 6, run code in develop mode and ensure that the first two tests in main.cpp pass. Then
submit code and ensure that the first two unit tests pass. Step 6: Implement ExtendedAVLTree's
GetNthKey() member function (worst case O(log n)) GetNthKey0 must return the tree's nth-largest
key. The parameter n starts at 0 for the smallest key in the tree. Ex: Suppose a tree has keys: 10,
19,20,30,42,55,77 Then GetNthKey (0) returns 10, GetNthKey (1) retums 19,.. GetNthKey (5)
returns 55, and GetNthKey (6) returns 77. Determine an algorithm that uses the subtree key
counts so that GetNthKey ( operates in worst case O(logn) time.E imaineps76 height =(( leftheight
> rightHeight ) ? lettHeight : rightHeight )+1; 77 J 3; 78 80 Hendifdetete nodeToRenove;
AVLNode* nodeToRebalance =( AVLWode* ) parent; white (nodeTofebalance) f Rebalance(
nodeToRebalance); nodeToRebalance =( AVLNode* ) nodeToRebalance->GetParent () ; J return
true; ] virtual bool Removellade(B5TNode* nodeToPenove) override { return RemoveAVLNode
((AVLNode*) nodeToResove); f publtic: AVLTree() I f j;#ifndef BSTNODEVECTORVISITOR_H
#def ine BSTNODEVECTORVISITOR_H Hinclude #include svector> #include "BSTNodeVisitor, h
" 1/ BsTliodevectorvisitor storesi a vector of BsThode potnters. Each call to the 1/ Visitil function
pushes the node to the back of the vector. (I BSTModeVectorvisttor also checks for duplleate node
visits: 5 tnce a single // BSThicdevectorvisitor instance is neant to be used for at most one
traversal. I/ through a BST, visiting the saase node trite imples that a ctrcular I/ reference exists.
class BSTModeVectorVisitor: public BSTNodeVisitor { private: 1/ visitedset is used to ensure that
the exact sane node instance is not 1/ vistited more than one. std:zunordered_set< BSThodes>
visitedhodes; BSTModeVectorvisitor() { hasCircRef = false; J I/ Returna true if a circular reference
was discovered when visiting a node, 11 false otherwise. bool HasCircularReference() const {
return hasCircRef; 3 virtual bool Vistt(BSTNode* node) { 7/ Check if the mode was already visited,
If 50 , the tree has a circular if ( visitedSet, count ( node )>0)1

Weitere ähnliche Inhalte

Ähnlich wie Please code this in C++ and utilize only the codes listed be.pdf

Pharo, an innovative and open-source Smalltalk
Pharo, an innovative and open-source SmalltalkPharo, an innovative and open-source Smalltalk
Pharo, an innovative and open-source SmalltalkSerge Stinckwich
 
Re-checking the ReactOS project - a large report
Re-checking the ReactOS project - a large reportRe-checking the ReactOS project - a large report
Re-checking the ReactOS project - a large reportPVS-Studio
 
Brief analysis of Media Portal 2 bugs
Brief analysis of Media Portal 2 bugsBrief analysis of Media Portal 2 bugs
Brief analysis of Media Portal 2 bugsPVS-Studio
 
Linux version of PVS-Studio couldn't help checking CodeLite
Linux version of PVS-Studio couldn't help checking CodeLiteLinux version of PVS-Studio couldn't help checking CodeLite
Linux version of PVS-Studio couldn't help checking CodeLitePVS-Studio
 
Elegant Solutions for Everyday Python Problems Pycon 2018 - Nina Zakharenko
Elegant Solutions for Everyday Python Problems Pycon 2018 - Nina ZakharenkoElegant Solutions for Everyday Python Problems Pycon 2018 - Nina Zakharenko
Elegant Solutions for Everyday Python Problems Pycon 2018 - Nina ZakharenkoNina Zakharenko
 
Analyzing ReactOS One More Time
Analyzing ReactOS One More TimeAnalyzing ReactOS One More Time
Analyzing ReactOS One More TimePVS-Studio
 
What's New In Python 2.6
What's New In Python 2.6What's New In Python 2.6
What's New In Python 2.6Richard Jones
 
#ifndef CRYPTO_HPP#define CRYPTO_HPP#include functional#.docx
#ifndef CRYPTO_HPP#define CRYPTO_HPP#include functional#.docx#ifndef CRYPTO_HPP#define CRYPTO_HPP#include functional#.docx
#ifndef CRYPTO_HPP#define CRYPTO_HPP#include functional#.docxgertrudebellgrove
 
(E Book) Asp .Net Tips, Tutorials And Code
(E Book) Asp .Net Tips,  Tutorials And Code(E Book) Asp .Net Tips,  Tutorials And Code
(E Book) Asp .Net Tips, Tutorials And Codesyedjee
 
1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answersAkash Gawali
 
Introduction to nsubstitute
Introduction to nsubstituteIntroduction to nsubstitute
Introduction to nsubstituteSuresh Loganatha
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++msharshitha03s
 
Código Saudável => Programador Feliz - Rs on Rails 2010
Código Saudável => Programador Feliz - Rs on Rails 2010Código Saudável => Programador Feliz - Rs on Rails 2010
Código Saudável => Programador Feliz - Rs on Rails 2010Plataformatec
 

Ähnlich wie Please code this in C++ and utilize only the codes listed be.pdf (20)

Pharo, an innovative and open-source Smalltalk
Pharo, an innovative and open-source SmalltalkPharo, an innovative and open-source Smalltalk
Pharo, an innovative and open-source Smalltalk
 
Re-checking the ReactOS project - a large report
Re-checking the ReactOS project - a large reportRe-checking the ReactOS project - a large report
Re-checking the ReactOS project - a large report
 
Brief analysis of Media Portal 2 bugs
Brief analysis of Media Portal 2 bugsBrief analysis of Media Portal 2 bugs
Brief analysis of Media Portal 2 bugs
 
Linux version of PVS-Studio couldn't help checking CodeLite
Linux version of PVS-Studio couldn't help checking CodeLiteLinux version of PVS-Studio couldn't help checking CodeLite
Linux version of PVS-Studio couldn't help checking CodeLite
 
Python_UNIT-I.pptx
Python_UNIT-I.pptxPython_UNIT-I.pptx
Python_UNIT-I.pptx
 
Elegant Solutions for Everyday Python Problems Pycon 2018 - Nina Zakharenko
Elegant Solutions for Everyday Python Problems Pycon 2018 - Nina ZakharenkoElegant Solutions for Everyday Python Problems Pycon 2018 - Nina Zakharenko
Elegant Solutions for Everyday Python Problems Pycon 2018 - Nina Zakharenko
 
Java tut1
Java tut1Java tut1
Java tut1
 
Tutorial java
Tutorial javaTutorial java
Tutorial java
 
Java Tut1
Java Tut1Java Tut1
Java Tut1
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 
Analyzing ReactOS One More Time
Analyzing ReactOS One More TimeAnalyzing ReactOS One More Time
Analyzing ReactOS One More Time
 
TY.BSc.IT Java QB U1
TY.BSc.IT Java QB U1TY.BSc.IT Java QB U1
TY.BSc.IT Java QB U1
 
What's New In Python 2.6
What's New In Python 2.6What's New In Python 2.6
What's New In Python 2.6
 
Annotation processing
Annotation processingAnnotation processing
Annotation processing
 
#ifndef CRYPTO_HPP#define CRYPTO_HPP#include functional#.docx
#ifndef CRYPTO_HPP#define CRYPTO_HPP#include functional#.docx#ifndef CRYPTO_HPP#define CRYPTO_HPP#include functional#.docx
#ifndef CRYPTO_HPP#define CRYPTO_HPP#include functional#.docx
 
(E Book) Asp .Net Tips, Tutorials And Code
(E Book) Asp .Net Tips,  Tutorials And Code(E Book) Asp .Net Tips,  Tutorials And Code
(E Book) Asp .Net Tips, Tutorials And Code
 
1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers
 
Introduction to nsubstitute
Introduction to nsubstituteIntroduction to nsubstitute
Introduction to nsubstitute
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++
 
Código Saudável => Programador Feliz - Rs on Rails 2010
Código Saudável => Programador Feliz - Rs on Rails 2010Código Saudável => Programador Feliz - Rs on Rails 2010
Código Saudável => Programador Feliz - Rs on Rails 2010
 

Mehr von kitty811

please fix this code so that the tests pass css Selec.pdf
please fix this code so that the tests pass        css Selec.pdfplease fix this code so that the tests pass        css Selec.pdf
please fix this code so that the tests pass css Selec.pdfkitty811
 
please help Below are the ages at which US presidents bega.pdf
please help Below are the ages at which US presidents bega.pdfplease help Below are the ages at which US presidents bega.pdf
please help Below are the ages at which US presidents bega.pdfkitty811
 
please fill in the blanks below the proc structure .pdf
please fill in the blanks below    the proc structure  .pdfplease fill in the blanks below    the proc structure  .pdf
please fill in the blanks below the proc structure .pdfkitty811
 
Please explain these steps Not sure how to go from first li.pdf
Please explain these steps Not sure how to go from first li.pdfPlease explain these steps Not sure how to go from first li.pdf
Please explain these steps Not sure how to go from first li.pdfkitty811
 
Please help Edgar Given the following API for a mutable Em.pdf
Please help Edgar Given the following API for a mutable Em.pdfPlease help Edgar Given the following API for a mutable Em.pdf
Please help Edgar Given the following API for a mutable Em.pdfkitty811
 
Please help 1 Use any data structures or control flows as a.pdf
Please help 1 Use any data structures or control flows as a.pdfPlease help 1 Use any data structures or control flows as a.pdf
Please help 1 Use any data structures or control flows as a.pdfkitty811
 
Please graph the spectrum using only MATLAB and provide the .pdf
Please graph the spectrum using only MATLAB and provide the .pdfPlease graph the spectrum using only MATLAB and provide the .pdf
Please graph the spectrum using only MATLAB and provide the .pdfkitty811
 
please help Let X and Y be random variables with joint dens.pdf
please help  Let X and Y be random variables with joint dens.pdfplease help  Let X and Y be random variables with joint dens.pdf
please help Let X and Y be random variables with joint dens.pdfkitty811
 
Please go through the Review Article and submit a summary of.pdf
Please go through the Review Article and submit a summary of.pdfPlease go through the Review Article and submit a summary of.pdf
Please go through the Review Article and submit a summary of.pdfkitty811
 
Please give me a new topic not the one already on cheggQU.pdf
Please give me a new topic not the one already on cheggQU.pdfPlease give me a new topic not the one already on cheggQU.pdf
Please give me a new topic not the one already on cheggQU.pdfkitty811
 
please give ANY inswer in 30 min The CONTROL pyloric rhythm .pdf
please give ANY inswer in 30 min The CONTROL pyloric rhythm .pdfplease give ANY inswer in 30 min The CONTROL pyloric rhythm .pdf
please give ANY inswer in 30 min The CONTROL pyloric rhythm .pdfkitty811
 
please full it please full it 2 Genie and Dan have just ha.pdf
please full it please full it 2 Genie and Dan have just ha.pdfplease full it please full it 2 Genie and Dan have just ha.pdf
please full it please full it 2 Genie and Dan have just ha.pdfkitty811
 
Please find the Below YAML code whihc is meant to achieve th.pdf
Please find the Below YAML code whihc is meant to achieve th.pdfPlease find the Below YAML code whihc is meant to achieve th.pdf
Please find the Below YAML code whihc is meant to achieve th.pdfkitty811
 
Please fix my errors class Iterator public Construc.pdf
Please fix my errors   class Iterator  public  Construc.pdfPlease fix my errors   class Iterator  public  Construc.pdf
Please fix my errors class Iterator public Construc.pdfkitty811
 
Please fill in the blanks of the 5 questions Required inform.pdf
Please fill in the blanks of the 5 questions Required inform.pdfPlease fill in the blanks of the 5 questions Required inform.pdf
Please fill in the blanks of the 5 questions Required inform.pdfkitty811
 
please fast answer Suppose that XU nif 01 You draw a sa.pdf
please fast answer  Suppose that XU nif 01 You draw a sa.pdfplease fast answer  Suppose that XU nif 01 You draw a sa.pdf
please fast answer Suppose that XU nif 01 You draw a sa.pdfkitty811
 
Please explain in steps so I may be able to follow and learn.pdf
Please explain in steps so I may be able to follow and learn.pdfPlease explain in steps so I may be able to follow and learn.pdf
Please explain in steps so I may be able to follow and learn.pdfkitty811
 
Please explain why c is correct Why does this return and e.pdf
Please explain why c is correct  Why does this return and e.pdfPlease explain why c is correct  Why does this return and e.pdf
Please explain why c is correct Why does this return and e.pdfkitty811
 
Please code in C in Visual Studio Thank you 1 Create a C.pdf
Please code in C in Visual Studio Thank you 1 Create a C.pdfPlease code in C in Visual Studio Thank you 1 Create a C.pdf
Please code in C in Visual Studio Thank you 1 Create a C.pdfkitty811
 
Please explain step by step Current Attempt in Progress As .pdf
Please explain step by step Current Attempt in Progress As .pdfPlease explain step by step Current Attempt in Progress As .pdf
Please explain step by step Current Attempt in Progress As .pdfkitty811
 

Mehr von kitty811 (20)

please fix this code so that the tests pass css Selec.pdf
please fix this code so that the tests pass        css Selec.pdfplease fix this code so that the tests pass        css Selec.pdf
please fix this code so that the tests pass css Selec.pdf
 
please help Below are the ages at which US presidents bega.pdf
please help Below are the ages at which US presidents bega.pdfplease help Below are the ages at which US presidents bega.pdf
please help Below are the ages at which US presidents bega.pdf
 
please fill in the blanks below the proc structure .pdf
please fill in the blanks below    the proc structure  .pdfplease fill in the blanks below    the proc structure  .pdf
please fill in the blanks below the proc structure .pdf
 
Please explain these steps Not sure how to go from first li.pdf
Please explain these steps Not sure how to go from first li.pdfPlease explain these steps Not sure how to go from first li.pdf
Please explain these steps Not sure how to go from first li.pdf
 
Please help Edgar Given the following API for a mutable Em.pdf
Please help Edgar Given the following API for a mutable Em.pdfPlease help Edgar Given the following API for a mutable Em.pdf
Please help Edgar Given the following API for a mutable Em.pdf
 
Please help 1 Use any data structures or control flows as a.pdf
Please help 1 Use any data structures or control flows as a.pdfPlease help 1 Use any data structures or control flows as a.pdf
Please help 1 Use any data structures or control flows as a.pdf
 
Please graph the spectrum using only MATLAB and provide the .pdf
Please graph the spectrum using only MATLAB and provide the .pdfPlease graph the spectrum using only MATLAB and provide the .pdf
Please graph the spectrum using only MATLAB and provide the .pdf
 
please help Let X and Y be random variables with joint dens.pdf
please help  Let X and Y be random variables with joint dens.pdfplease help  Let X and Y be random variables with joint dens.pdf
please help Let X and Y be random variables with joint dens.pdf
 
Please go through the Review Article and submit a summary of.pdf
Please go through the Review Article and submit a summary of.pdfPlease go through the Review Article and submit a summary of.pdf
Please go through the Review Article and submit a summary of.pdf
 
Please give me a new topic not the one already on cheggQU.pdf
Please give me a new topic not the one already on cheggQU.pdfPlease give me a new topic not the one already on cheggQU.pdf
Please give me a new topic not the one already on cheggQU.pdf
 
please give ANY inswer in 30 min The CONTROL pyloric rhythm .pdf
please give ANY inswer in 30 min The CONTROL pyloric rhythm .pdfplease give ANY inswer in 30 min The CONTROL pyloric rhythm .pdf
please give ANY inswer in 30 min The CONTROL pyloric rhythm .pdf
 
please full it please full it 2 Genie and Dan have just ha.pdf
please full it please full it 2 Genie and Dan have just ha.pdfplease full it please full it 2 Genie and Dan have just ha.pdf
please full it please full it 2 Genie and Dan have just ha.pdf
 
Please find the Below YAML code whihc is meant to achieve th.pdf
Please find the Below YAML code whihc is meant to achieve th.pdfPlease find the Below YAML code whihc is meant to achieve th.pdf
Please find the Below YAML code whihc is meant to achieve th.pdf
 
Please fix my errors class Iterator public Construc.pdf
Please fix my errors   class Iterator  public  Construc.pdfPlease fix my errors   class Iterator  public  Construc.pdf
Please fix my errors class Iterator public Construc.pdf
 
Please fill in the blanks of the 5 questions Required inform.pdf
Please fill in the blanks of the 5 questions Required inform.pdfPlease fill in the blanks of the 5 questions Required inform.pdf
Please fill in the blanks of the 5 questions Required inform.pdf
 
please fast answer Suppose that XU nif 01 You draw a sa.pdf
please fast answer  Suppose that XU nif 01 You draw a sa.pdfplease fast answer  Suppose that XU nif 01 You draw a sa.pdf
please fast answer Suppose that XU nif 01 You draw a sa.pdf
 
Please explain in steps so I may be able to follow and learn.pdf
Please explain in steps so I may be able to follow and learn.pdfPlease explain in steps so I may be able to follow and learn.pdf
Please explain in steps so I may be able to follow and learn.pdf
 
Please explain why c is correct Why does this return and e.pdf
Please explain why c is correct  Why does this return and e.pdfPlease explain why c is correct  Why does this return and e.pdf
Please explain why c is correct Why does this return and e.pdf
 
Please code in C in Visual Studio Thank you 1 Create a C.pdf
Please code in C in Visual Studio Thank you 1 Create a C.pdfPlease code in C in Visual Studio Thank you 1 Create a C.pdf
Please code in C in Visual Studio Thank you 1 Create a C.pdf
 
Please explain step by step Current Attempt in Progress As .pdf
Please explain step by step Current Attempt in Progress As .pdfPlease explain step by step Current Attempt in Progress As .pdf
Please explain step by step Current Attempt in Progress As .pdf
 

Kürzlich hochgeladen

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Kürzlich hochgeladen (20)

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

Please code this in C++ and utilize only the codes listed be.pdf

  • 1. Please code this in C++ and utilize only the codes listed below. I need help on coding both ExtendedAVLTree.h and ExtendedAVLNode.h. I'm especially confused about ExtendedAVLTree.h since from what I understand, we are supposed to override InsertNode and DeleteNode in the ExtendedAVLTree.h file. Please take the time to look at this carefully. Thank you main.cpp AVLNode.h AVLTree.h BinarySearchTree.h BSTNode.h BSTNodeVector.h BSTNodeVectorVisitor.h ExtendedAVLNode.h #ifndef EXTENDEDAVLNODE_H #define EXTENDEDAVLNODE_H #include "AVLNode.h" class ExtendedAVLNode : public AVLNode { private: int subtreeKeyCount; public: ExtendedAVLNode(int nodeKey) : AVLNode(nodeKey) { subtreeKeyCount = 1; } virtual int GetSubtreeKeyCount() override { return subtreeKeyCount; } // Your code here virtual void UpdateSubtreeKeyCount(BSTNode* node) { int count = 1; if (GetLeft() != NULL) { count += ((ExtendedAVLNode*) GetLeft())->GetSubtreeKeyCount(); } if (GetRight() != NULL) { count += ((ExtendedAVLNode*) GetRight())->GetSubtreeKeyCount(); } subtreeKeyCount = count; } };
  • 2. #endif ExtendedAVLTree.h #ifndef EXTENDEDAVLTREE_H #define EXTENDEDAVLTREE_H #include "AVLTree.h" #include "ExtendedAVLNode.h" class ExtendedAVLTree : public AVLTree { protected: // Each node in an ExtendedAVLTree is an ExtendedAVLNode virtual BSTNode* MakeNewNode(int key) override { return new ExtendedAVLNode(key); } // Your code here public: virtual int GetNthKey(int n) override { // Your code here (remove placeholder line below) return 0; } }; #endif 8.11 LAB: AVL tree Nth largest operation Step 1: Inspect the BSTNode.h and BinarySearchTree.h files Inspect the BSTNode class declaration for a binary search tree node in BSTNode h. Access BSTNode h by clicking on the orange arrow next to main, cpp at the top of the coding window. The BSTNode class has private member variables for the key, parent pointer, left child pointer. and right child pointer. Accessor functions exist for each. Inspect the BinarySearchTree class declaration for a binary search tree node in BinarySearchTree.h. The GetNthKey0 function is the only pure virtual function that exists. Step 2: Inspect other files related to the inheritance hierarchy Classes AVLNode and AVLTree inherit from BSTNode and BinarySearchTree, respectively. Each class is implemented in a read only header file. Classes ExtendedAVLNode and ExtendedAVLTree are declared, but implementations are incomplete. Both classes must be implemented in this lab. Read only, completed class implementation Incomplete class implementation Step 3: Understand the purpose of the subtreeKeyCount variable The ExtendedAVLNode class inherits from AVLNode and adds one integer member variable, subtreeKeyCount. Each node's subtree key count is the number of keys in the subtree rooted at that node. Ex. lunt ExtendedAVLNode's constructor and GetSubtreeKeyCount() member functions are already implemented and should not be changed Additional member functions are needed to ensure that subtreekeycount remains accurate Step 4: Implement ExtendedAVLTree and ExtendedAVLNode Each node in an ExtendedAVLTree must have a correct subtreekeyCount after an insertion or removal operation. Determine which member functions in AVLTree and AVLNode must be overridden in ExtendedAVLTree and ExtendedAVLNode to keep each node's subtreeKeyCount. correct. New functions can be added along with overridden functions, if desired. Hint Consider an UpdateSubtreekeyCount O member function for the ExtendedAVLNode class.
  • 3. The function requires each child node's subtreekeycount to be correct, and updates the node's subtreekeyCount appropriately. Overridden functions in both ExtendedAVLNode and ExtendedAVLTree can call a node's UpdateSubtreeKeyCount() function as needed Once determinations are made, complete the implementation of both the ExtendediALTree and ExtendedAVLNode classes. Do not implement ExtendedAVLTree's GetNthKeyO in this step. GetNthKeyO requires correct subtree counts at each node Step 5: Run tests in develop mode and submit mode TreeTestCommand is an abstract base class defined in TreeCommands.h. A TreeTestCommand object is an executable command that operates on a binary search tree. Classes inheriting from TreeTestCommand are also declared in TreeCommands.h - TreeinsertCommand inserts keys into the tree - TreeRemoveCommand removes keys from the tree - TreeverifykeysCommand verifies the tree's keys using an inorder traversal - TreeverifysubtreeCountscommand verifies that each node in the tree has the expected subtree key count - TreeGetNthCommand verifies that GetNithkey(0 returns an expected value Code in main.opp contains three automated test cases. Each test executes a vector of TreeTestCommand objects in sequence. The third test includes TreeGetNthcommands and will not pass until the completion of Step 6. The first two tests should pass after completion of step4. Before proceeding to Step 6, run code in develop mode and ensure that the first two tests in main.cpp pass. Then submit code and ensure that the first two unit tests pass. Step 6: Implement ExtendedAVLTree's GetNthKey() member function (worst case O(log n)) GetNthKey0 must return the tree's nth-largest key. The parameter n starts at 0 for the smallest key in the tree. Ex: Suppose a tree has keys: 10, 19,20,30,42,55,77 Then GetNthKey (0) returns 10, GetNthKey (1) retums 19,.. GetNthKey (5) returns 55, and GetNthKey (6) returns 77. Determine an algorithm that uses the subtree key counts so that GetNthKey ( operates in worst case O(logn) time.E imaineps76 height =(( leftheight > rightHeight ) ? lettHeight : rightHeight )+1; 77 J 3; 78 80 Hendifdetete nodeToRenove; AVLNode* nodeToRebalance =( AVLWode* ) parent; white (nodeTofebalance) f Rebalance( nodeToRebalance); nodeToRebalance =( AVLNode* ) nodeToRebalance->GetParent () ; J return true; ] virtual bool Removellade(B5TNode* nodeToPenove) override { return RemoveAVLNode ((AVLNode*) nodeToResove); f publtic: AVLTree() I f j;#ifndef BSTNODEVECTORVISITOR_H #def ine BSTNODEVECTORVISITOR_H Hinclude #include svector> #include "BSTNodeVisitor, h " 1/ BsTliodevectorvisitor storesi a vector of BsThode potnters. Each call to the 1/ Visitil function pushes the node to the back of the vector. (I BSTModeVectorvisttor also checks for duplleate node visits: 5 tnce a single // BSThicdevectorvisitor instance is neant to be used for at most one traversal. I/ through a BST, visiting the saase node trite imples that a ctrcular I/ reference exists. class BSTModeVectorVisitor: public BSTNodeVisitor { private: 1/ visitedset is used to ensure that the exact sane node instance is not 1/ vistited more than one. std:zunordered_set< BSThodes> visitedhodes; BSTModeVectorvisitor() { hasCircRef = false; J I/ Returna true if a circular reference was discovered when visiting a node, 11 false otherwise. bool HasCircularReference() const { return hasCircRef; 3 virtual bool Vistt(BSTNode* node) { 7/ Check if the mode was already visited, If 50 , the tree has a circular if ( visitedSet, count ( node )>0)1