SlideShare a Scribd company logo
Help implement BST. The code must follow the instruction below as well as produce the
correct output when testing with the input file I'll provide at the end. Please fill-in the
TODO parts in the bst.cc code:
INSTRUCTIONS:
3. First, implement the BST (declared in bst.h) and use the unittest_bst() function to test it. DO
NOT CHANGE THIS CODE FOR YOUR SUBMISSION, as it will be used to test your code
against the answers (with different seed values).
4. Implement the DB and use the unittest_db() function to test it. DO NOT CHANGE THIS
CODE FOR YOUR SUBMISSION, as it will be used to test your code against the answers (with
different input files).
a) The student ID should be the base class's key member.
b) The student ID should be automatically assigned such that the ID/key should be n if the
student is the nth student to join the school. If the student later leaves (i.e., deleted from the
BST), the ID does NOT get reassigned to another student. Thus, the student ID of the last student
to join the school should reflect the TOTAL number of students that have joined this school
since its reception (regardless of whether some have left).
5. Test your code against the provided input and output files.
a) The provided answer for the BST unit test is in "unittest_ans_t100_s100.txt". The s100 refers
to the seed of 100 (-s 100), and t100 refers to the number of elements to add to the BST (-t 100).
b) The provided answer for the DB is in "students_1_ans.txt" for the "students_1.txt" input file.
6. Make sure your code has no memory leaks (using valgrind).
7. Your code should work beyond the provided unit tests. That is, even if it does work for all the
given tests, if the code has an identifiable bug (i.e., by reading the source code), points WILL be
deducted.
For example, if I were to change
unittest_bst(num_test, seed, cout, 5); ->
unittest_bst(num_test, seed, cout, 100);
it should still work.
BST.H
#ifndef BST_H_
#define BST_H_
#include <iostream>
using namespace std;
class Node {
private:
int key;
Node* parent;
Node* left;
Node* right;
public:
// Default constructor
Node();
// Constructor
Node(int in);
// Destructor
// a virtual constructor is required for inheritance
virtual ~Node();
// Add to parent of current node
void add_parent(Node* in);
// Add to left of current node
void add_left(Node* in);
// Add to right of current node
void add_right(Node* in);
// Get key
int get_key();
// Get parent node
Node* get_parent();
// Get left node
Node* get_left();
// Get right node
Node* get_right();
virtual void print_info(ostream& to);
};
class BST {
private:
Node* root;
// Walk the subtree from the given node
void inorder_walk(Node* in, ostream& to);
// Get the minimum node from the subtree of given node
Node* get_min(Node* in);
// Get the maximum node from the subtree of given node
Node* get_max(Node* in);
public:
// Constructor and Destructor
BST();
~BST();
// Modify tree
void insert_node(Node* in);
void delete_node(Node* out);
// Find nodes in the tree
Node* tree_min(); // minimum key value
Node* tree_max(); // maximum key value
Node* get_succ(Node* in); // successor for a given node
Node* get_pred(Node* in); // predecessor for a given node
void walk(ostream& to); // Traverse the tree from min to max recursively
Node* tree_search(int search_key);
};
#endif
COMLPETE THIS PART, BST.CC
#include "bst.h"
// ---------------------------------------
// Node class
// Default constructor
Node::Node() {
// TODO: Implement this
}
// Constructor
Node::Node(int in) {
// TODO: Implement this
}
// Destructor
Node::~Node() {
// TODO: Implement this
}
// Add parent
void Node::add_parent(Node* in) {
// TODO: Implement this
}
// Add to left of current node
void Node::add_left(Node* in) {
// TODO: Implement this
}
// Add to right of current node
void Node::add_right(Node* in) {
// TODO: Implement this
}
// Get key
int Node::get_key()
{
// TODO: Implement this
}
// Get parent node
Node* Node::get_parent()
{
// TODO: Implement this
}
// Get left node
Node* Node::get_left()
{
// TODO: Implement this
}
// Get right node
Node* Node::get_right()
{
// TODO: Implement this
}
// Print the key to ostream to
// Do not change this
void Node::print_info(ostream& to)
{
to << key << endl;
}
// ---------------------------------------
// ---------------------------------------
// BST class
// Walk the subtree from the given node
void BST::inorder_walk(Node* in, ostream& to)
{
// TODO: Implement this
}
// Constructor
BST::BST()
{
// TODO: Implement this
}
// Destructor
BST::~BST()
{
// TODO: Implement this
}
// Insert a node to the subtree
void BST::insert_node(Node* in)
{
// TODO: Implement this
}
// Delete a node to the subtree
void BST::delete_node(Node* out)
{
// TODO: Implement this
}
// minimum key in the BST
Node* BST::tree_min()
{
// TODO: Implement this
}
// maximum key in the BST
Node* BST::tree_max()
{
// TODO: Implement this
}
// Get the minimum node from the subtree of given node
Node* BST::get_min(Node* in)
{
// TODO: Implement this
}
// Get the maximum node from the subtree of given node
Node* BST::get_max(Node* in)
{
// TODO: Implement this
}
// Get successor of the given node
Node* BST::get_succ(Node* in)
{
// TODO: Implement this
}
// Get predecessor of the given node
Node* BST::get_pred(Node* in)
{
// TODO: Implement this
}
// Walk the BST from min to max
void BST::walk(ostream& to)
{
// TODO: Implement this
}
// Search the tree for a given key
Node* BST::tree_search(int search_key)
{
// TODO: Implement this
}
// ---------------------------------------
INPUT FILE:
Noel Cummings 83
Kian Avery 86
Eliana Knox 77
Paisley Peck 15
Michael Mcgrath 93
Makayla Dixon 35
Mara Singh 86
Aaliyah Arias 92
Hector Nicholson 49
Leo Holder 21
Dangelo Ball 62
Dario Kaufman 27
Brett Ho 90
Jamarcus Castro 59
Sheldon Burnett 63
Van Bautista 26
Gabriel Kelley 40
Kristin Walker 26
Stephany Figueroa 72
Carsen Mullen 36
Wendy Singh 11
Ava Carlson 68
Vaughn Boone 67
Grant Simpson 29
Urijah Oneal 82
Melissa Larson 30
Javier George 62
Roland Walters 23
Brooklyn Mcpherson 67
Cayden Mccarthy 35
Dixie Parrish 29
Jaslyn Hinton 2
Rory Hahn 22
Diamond Lawson 58
Jasper Franco 69
Kendal Wheeler 67
Odin Browning 93
Kenna Benson 56
Reese Walters 11
Thalia Tran 42
Chad Horton 29
Asher Cardenas 73
Angel Finley 21
Charlotte Gray 19
Delilah Hoover 84
Drew Mckenzie 37
Brandon Mahoney 98
Cristian Chandler 24
Leonel Briggs 15
Gracie Buchanan 70

More Related Content

Similar to Help implement BST- The code must follow the instruction below as well.pdf

Data Structures and Agorithm: DS 14 Binary Expression Tree.pptx
Data Structures and Agorithm: DS 14 Binary Expression Tree.pptxData Structures and Agorithm: DS 14 Binary Expression Tree.pptx
Data Structures and Agorithm: DS 14 Binary Expression Tree.pptx
RashidFaridChishti
 
(Parent reference for BST) Redefine TreeNode by adding a reference to.pdf
(Parent reference for BST) Redefine TreeNode by adding a reference to.pdf(Parent reference for BST) Redefine TreeNode by adding a reference to.pdf
(Parent reference for BST) Redefine TreeNode by adding a reference to.pdf
arihantelehyb
 
BSTNode.Java Node class used for implementing the BST. .pdf
BSTNode.Java   Node class used for implementing the BST. .pdfBSTNode.Java   Node class used for implementing the BST. .pdf
BSTNode.Java Node class used for implementing the BST. .pdf
info189835
 
Introduction to CUDA C: NVIDIA : Notes
Introduction to CUDA C: NVIDIA : NotesIntroduction to CUDA C: NVIDIA : Notes
Introduction to CUDA C: NVIDIA : Notes
Subhajit Sahu
 
write recursive function that calculates and returns the length of a.pdf
write recursive function that calculates and returns the length of a.pdfwrite recursive function that calculates and returns the length of a.pdf
write recursive function that calculates and returns the length of a.pdf
arpitcomputronics
 
C++, Implement the class BinarySearchTree, as given in listing 16-4 .pdf
C++, Implement the class BinarySearchTree, as given in listing 16-4 .pdfC++, Implement the class BinarySearchTree, as given in listing 16-4 .pdf
C++, Implement the class BinarySearchTree, as given in listing 16-4 .pdf
rohit219406
 
Virtual Function and Polymorphism.ppt
Virtual Function and Polymorphism.pptVirtual Function and Polymorphism.ppt
Virtual Function and Polymorphism.ppt
ishan743441
 
Algorithms devised for a google interview
Algorithms devised for a google interviewAlgorithms devised for a google interview
Algorithms devised for a google interview
Russell Childs
 
In c++ format please, for each function in the code, using the comme.pdf
In c++ format please, for each function in the code, using the comme.pdfIn c++ format please, for each function in the code, using the comme.pdf
In c++ format please, for each function in the code, using the comme.pdf
ezycolours78
 
C1320prespost
C1320prespostC1320prespost
C1320prespost
FALLEE31188
 
C++11
C++11C++11
Question In C Programming In mathematics, a set is a colle...Sav.pdf
Question In C Programming In mathematics, a set is a colle...Sav.pdfQuestion In C Programming In mathematics, a set is a colle...Sav.pdf
Question In C Programming In mathematics, a set is a colle...Sav.pdf
arihantcomp1008
 
Linked list
Linked listLinked list
Linked list
somuinfo123
 
C++11 - STL Additions
C++11 - STL AdditionsC++11 - STL Additions
C++11 - STL Additions
GlobalLogic Ukraine
 
This is a c++ binary search program I worked so far but still cant g.pdf
This is a c++ binary search program I worked so far but still cant g.pdfThis is a c++ binary search program I worked so far but still cant g.pdf
This is a c++ binary search program I worked so far but still cant g.pdf
kostikjaylonshaewe47
 
"Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov
Fwdays
 
String searching
String searchingString searching
String searching
Russell Childs
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
Divye Kapoor
 
COW
COWCOW
Lab 13
Lab 13Lab 13
Lab 13
Adnan Raza
 

Similar to Help implement BST- The code must follow the instruction below as well.pdf (20)

Data Structures and Agorithm: DS 14 Binary Expression Tree.pptx
Data Structures and Agorithm: DS 14 Binary Expression Tree.pptxData Structures and Agorithm: DS 14 Binary Expression Tree.pptx
Data Structures and Agorithm: DS 14 Binary Expression Tree.pptx
 
(Parent reference for BST) Redefine TreeNode by adding a reference to.pdf
(Parent reference for BST) Redefine TreeNode by adding a reference to.pdf(Parent reference for BST) Redefine TreeNode by adding a reference to.pdf
(Parent reference for BST) Redefine TreeNode by adding a reference to.pdf
 
BSTNode.Java Node class used for implementing the BST. .pdf
BSTNode.Java   Node class used for implementing the BST. .pdfBSTNode.Java   Node class used for implementing the BST. .pdf
BSTNode.Java Node class used for implementing the BST. .pdf
 
Introduction to CUDA C: NVIDIA : Notes
Introduction to CUDA C: NVIDIA : NotesIntroduction to CUDA C: NVIDIA : Notes
Introduction to CUDA C: NVIDIA : Notes
 
write recursive function that calculates and returns the length of a.pdf
write recursive function that calculates and returns the length of a.pdfwrite recursive function that calculates and returns the length of a.pdf
write recursive function that calculates and returns the length of a.pdf
 
C++, Implement the class BinarySearchTree, as given in listing 16-4 .pdf
C++, Implement the class BinarySearchTree, as given in listing 16-4 .pdfC++, Implement the class BinarySearchTree, as given in listing 16-4 .pdf
C++, Implement the class BinarySearchTree, as given in listing 16-4 .pdf
 
Virtual Function and Polymorphism.ppt
Virtual Function and Polymorphism.pptVirtual Function and Polymorphism.ppt
Virtual Function and Polymorphism.ppt
 
Algorithms devised for a google interview
Algorithms devised for a google interviewAlgorithms devised for a google interview
Algorithms devised for a google interview
 
In c++ format please, for each function in the code, using the comme.pdf
In c++ format please, for each function in the code, using the comme.pdfIn c++ format please, for each function in the code, using the comme.pdf
In c++ format please, for each function in the code, using the comme.pdf
 
C1320prespost
C1320prespostC1320prespost
C1320prespost
 
C++11
C++11C++11
C++11
 
Question In C Programming In mathematics, a set is a colle...Sav.pdf
Question In C Programming In mathematics, a set is a colle...Sav.pdfQuestion In C Programming In mathematics, a set is a colle...Sav.pdf
Question In C Programming In mathematics, a set is a colle...Sav.pdf
 
Linked list
Linked listLinked list
Linked list
 
C++11 - STL Additions
C++11 - STL AdditionsC++11 - STL Additions
C++11 - STL Additions
 
This is a c++ binary search program I worked so far but still cant g.pdf
This is a c++ binary search program I worked so far but still cant g.pdfThis is a c++ binary search program I worked so far but still cant g.pdf
This is a c++ binary search program I worked so far but still cant g.pdf
 
"Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov
 
String searching
String searchingString searching
String searching
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
 
COW
COWCOW
COW
 
Lab 13
Lab 13Lab 13
Lab 13
 

More from a2zmobiles

7- Match the astronomer to his accomplishment a- Ptolemy i- Made very.pdf
7- Match the astronomer to his accomplishment a- Ptolemy i- Made very.pdf7- Match the astronomer to his accomplishment a- Ptolemy i- Made very.pdf
7- Match the astronomer to his accomplishment a- Ptolemy i- Made very.pdf
a2zmobiles
 
7- In a multiple linear regression model y-X+-XN(0-2In)- the OLS estim (1).pdf
7- In a multiple linear regression model y-X+-XN(0-2In)- the OLS estim (1).pdf7- In a multiple linear regression model y-X+-XN(0-2In)- the OLS estim (1).pdf
7- In a multiple linear regression model y-X+-XN(0-2In)- the OLS estim (1).pdf
a2zmobiles
 
7- In addition to a pH imbalance- prolonged vomiting is also causing D.pdf
7- In addition to a pH imbalance- prolonged vomiting is also causing D.pdf7- In addition to a pH imbalance- prolonged vomiting is also causing D.pdf
7- In addition to a pH imbalance- prolonged vomiting is also causing D.pdf
a2zmobiles
 
7- The temperature at which a certain substance boils is normally dist.pdf
7- The temperature at which a certain substance boils is normally dist.pdf7- The temperature at which a certain substance boils is normally dist.pdf
7- The temperature at which a certain substance boils is normally dist.pdf
a2zmobiles
 
7- The length of time necessary to complete a specific task is exponen.pdf
7- The length of time necessary to complete a specific task is exponen.pdf7- The length of time necessary to complete a specific task is exponen.pdf
7- The length of time necessary to complete a specific task is exponen.pdf
a2zmobiles
 
7- The following data have been collected for a British healthcare IT.pdf
7- The following data have been collected for a British healthcare IT.pdf7- The following data have been collected for a British healthcare IT.pdf
7- The following data have been collected for a British healthcare IT.pdf
a2zmobiles
 
7- Many news organizations conduct polls asking adults in the United S.pdf
7- Many news organizations conduct polls asking adults in the United S.pdf7- Many news organizations conduct polls asking adults in the United S.pdf
7- Many news organizations conduct polls asking adults in the United S.pdf
a2zmobiles
 
7- Calculate - DV for the following foed label (For carbohydrate and F.pdf
7- Calculate - DV for the following foed label (For carbohydrate and F.pdf7- Calculate - DV for the following foed label (For carbohydrate and F.pdf
7- Calculate - DV for the following foed label (For carbohydrate and F.pdf
a2zmobiles
 
7- With the help of suitable examples- Explain how the application of.pdf
7- With the help of suitable examples- Explain how the application of.pdf7- With the help of suitable examples- Explain how the application of.pdf
7- With the help of suitable examples- Explain how the application of.pdf
a2zmobiles
 
7- A taxpayer's wife died in 2021 and he has not remarried- He has two.pdf
7- A taxpayer's wife died in 2021 and he has not remarried- He has two.pdf7- A taxpayer's wife died in 2021 and he has not remarried- He has two.pdf
7- A taxpayer's wife died in 2021 and he has not remarried- He has two.pdf
a2zmobiles
 
7- In his book- Alfred Wegener presented many lines of evidence that E.pdf
7- In his book- Alfred Wegener presented many lines of evidence that E.pdf7- In his book- Alfred Wegener presented many lines of evidence that E.pdf
7- In his book- Alfred Wegener presented many lines of evidence that E.pdf
a2zmobiles
 
7- In humans- the allele for normal blood clotting- H- is dominant to.pdf
7- In humans- the allele for normal blood clotting- H- is dominant to.pdf7- In humans- the allele for normal blood clotting- H- is dominant to.pdf
7- In humans- the allele for normal blood clotting- H- is dominant to.pdf
a2zmobiles
 
7- Examine the map of the Murky Mists Mountain- - D- INote tne strike.pdf
7- Examine the map of the Murky Mists Mountain- - D- INote tne strike.pdf7- Examine the map of the Murky Mists Mountain- - D- INote tne strike.pdf
7- Examine the map of the Murky Mists Mountain- - D- INote tne strike.pdf
a2zmobiles
 
7- 7- Caleulating Returns and Variability (LO1) Usine the followine re.pdf
7- 7- Caleulating Returns and Variability (LO1) Usine the followine re.pdf7- 7- Caleulating Returns and Variability (LO1) Usine the followine re.pdf
7- 7- Caleulating Returns and Variability (LO1) Usine the followine re.pdf
a2zmobiles
 
7- A perpetuity-immediate pays 1500 per year- Alice receives the first.pdf
7- A perpetuity-immediate pays 1500 per year- Alice receives the first.pdf7- A perpetuity-immediate pays 1500 per year- Alice receives the first.pdf
7- A perpetuity-immediate pays 1500 per year- Alice receives the first.pdf
a2zmobiles
 
7- A cohort study employs a- Subjects known at the start to have the d.pdf
7- A cohort study employs a- Subjects known at the start to have the d.pdf7- A cohort study employs a- Subjects known at the start to have the d.pdf
7- A cohort study employs a- Subjects known at the start to have the d.pdf
a2zmobiles
 
7- When I present the German Tank Problem- the most popular proposals.pdf
7- When I present the German Tank Problem- the most popular proposals.pdf7- When I present the German Tank Problem- the most popular proposals.pdf
7- When I present the German Tank Problem- the most popular proposals.pdf
a2zmobiles
 
7- (Microsoft Visual Basic) Display a triangle Hints- The following co.pdf
7- (Microsoft Visual Basic) Display a triangle Hints- The following co.pdf7- (Microsoft Visual Basic) Display a triangle Hints- The following co.pdf
7- (Microsoft Visual Basic) Display a triangle Hints- The following co.pdf
a2zmobiles
 
HELPPP Which of the following are differences in the recommendations.pdf
HELPPP   Which of the following are differences in the recommendations.pdfHELPPP   Which of the following are differences in the recommendations.pdf
HELPPP Which of the following are differences in the recommendations.pdf
a2zmobiles
 
Hemophilia is due to a recessive allele (h) linked to the X chromosome (1).pdf
Hemophilia is due to a recessive allele (h) linked to the X chromosome (1).pdfHemophilia is due to a recessive allele (h) linked to the X chromosome (1).pdf
Hemophilia is due to a recessive allele (h) linked to the X chromosome (1).pdf
a2zmobiles
 

More from a2zmobiles (20)

7- Match the astronomer to his accomplishment a- Ptolemy i- Made very.pdf
7- Match the astronomer to his accomplishment a- Ptolemy i- Made very.pdf7- Match the astronomer to his accomplishment a- Ptolemy i- Made very.pdf
7- Match the astronomer to his accomplishment a- Ptolemy i- Made very.pdf
 
7- In a multiple linear regression model y-X+-XN(0-2In)- the OLS estim (1).pdf
7- In a multiple linear regression model y-X+-XN(0-2In)- the OLS estim (1).pdf7- In a multiple linear regression model y-X+-XN(0-2In)- the OLS estim (1).pdf
7- In a multiple linear regression model y-X+-XN(0-2In)- the OLS estim (1).pdf
 
7- In addition to a pH imbalance- prolonged vomiting is also causing D.pdf
7- In addition to a pH imbalance- prolonged vomiting is also causing D.pdf7- In addition to a pH imbalance- prolonged vomiting is also causing D.pdf
7- In addition to a pH imbalance- prolonged vomiting is also causing D.pdf
 
7- The temperature at which a certain substance boils is normally dist.pdf
7- The temperature at which a certain substance boils is normally dist.pdf7- The temperature at which a certain substance boils is normally dist.pdf
7- The temperature at which a certain substance boils is normally dist.pdf
 
7- The length of time necessary to complete a specific task is exponen.pdf
7- The length of time necessary to complete a specific task is exponen.pdf7- The length of time necessary to complete a specific task is exponen.pdf
7- The length of time necessary to complete a specific task is exponen.pdf
 
7- The following data have been collected for a British healthcare IT.pdf
7- The following data have been collected for a British healthcare IT.pdf7- The following data have been collected for a British healthcare IT.pdf
7- The following data have been collected for a British healthcare IT.pdf
 
7- Many news organizations conduct polls asking adults in the United S.pdf
7- Many news organizations conduct polls asking adults in the United S.pdf7- Many news organizations conduct polls asking adults in the United S.pdf
7- Many news organizations conduct polls asking adults in the United S.pdf
 
7- Calculate - DV for the following foed label (For carbohydrate and F.pdf
7- Calculate - DV for the following foed label (For carbohydrate and F.pdf7- Calculate - DV for the following foed label (For carbohydrate and F.pdf
7- Calculate - DV for the following foed label (For carbohydrate and F.pdf
 
7- With the help of suitable examples- Explain how the application of.pdf
7- With the help of suitable examples- Explain how the application of.pdf7- With the help of suitable examples- Explain how the application of.pdf
7- With the help of suitable examples- Explain how the application of.pdf
 
7- A taxpayer's wife died in 2021 and he has not remarried- He has two.pdf
7- A taxpayer's wife died in 2021 and he has not remarried- He has two.pdf7- A taxpayer's wife died in 2021 and he has not remarried- He has two.pdf
7- A taxpayer's wife died in 2021 and he has not remarried- He has two.pdf
 
7- In his book- Alfred Wegener presented many lines of evidence that E.pdf
7- In his book- Alfred Wegener presented many lines of evidence that E.pdf7- In his book- Alfred Wegener presented many lines of evidence that E.pdf
7- In his book- Alfred Wegener presented many lines of evidence that E.pdf
 
7- In humans- the allele for normal blood clotting- H- is dominant to.pdf
7- In humans- the allele for normal blood clotting- H- is dominant to.pdf7- In humans- the allele for normal blood clotting- H- is dominant to.pdf
7- In humans- the allele for normal blood clotting- H- is dominant to.pdf
 
7- Examine the map of the Murky Mists Mountain- - D- INote tne strike.pdf
7- Examine the map of the Murky Mists Mountain- - D- INote tne strike.pdf7- Examine the map of the Murky Mists Mountain- - D- INote tne strike.pdf
7- Examine the map of the Murky Mists Mountain- - D- INote tne strike.pdf
 
7- 7- Caleulating Returns and Variability (LO1) Usine the followine re.pdf
7- 7- Caleulating Returns and Variability (LO1) Usine the followine re.pdf7- 7- Caleulating Returns and Variability (LO1) Usine the followine re.pdf
7- 7- Caleulating Returns and Variability (LO1) Usine the followine re.pdf
 
7- A perpetuity-immediate pays 1500 per year- Alice receives the first.pdf
7- A perpetuity-immediate pays 1500 per year- Alice receives the first.pdf7- A perpetuity-immediate pays 1500 per year- Alice receives the first.pdf
7- A perpetuity-immediate pays 1500 per year- Alice receives the first.pdf
 
7- A cohort study employs a- Subjects known at the start to have the d.pdf
7- A cohort study employs a- Subjects known at the start to have the d.pdf7- A cohort study employs a- Subjects known at the start to have the d.pdf
7- A cohort study employs a- Subjects known at the start to have the d.pdf
 
7- When I present the German Tank Problem- the most popular proposals.pdf
7- When I present the German Tank Problem- the most popular proposals.pdf7- When I present the German Tank Problem- the most popular proposals.pdf
7- When I present the German Tank Problem- the most popular proposals.pdf
 
7- (Microsoft Visual Basic) Display a triangle Hints- The following co.pdf
7- (Microsoft Visual Basic) Display a triangle Hints- The following co.pdf7- (Microsoft Visual Basic) Display a triangle Hints- The following co.pdf
7- (Microsoft Visual Basic) Display a triangle Hints- The following co.pdf
 
HELPPP Which of the following are differences in the recommendations.pdf
HELPPP   Which of the following are differences in the recommendations.pdfHELPPP   Which of the following are differences in the recommendations.pdf
HELPPP Which of the following are differences in the recommendations.pdf
 
Hemophilia is due to a recessive allele (h) linked to the X chromosome (1).pdf
Hemophilia is due to a recessive allele (h) linked to the X chromosome (1).pdfHemophilia is due to a recessive allele (h) linked to the X chromosome (1).pdf
Hemophilia is due to a recessive allele (h) linked to the X chromosome (1).pdf
 

Recently uploaded

How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
สมใจ จันสุกสี
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 

Recently uploaded (20)

How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 

Help implement BST- The code must follow the instruction below as well.pdf

  • 1. Help implement BST. The code must follow the instruction below as well as produce the correct output when testing with the input file I'll provide at the end. Please fill-in the TODO parts in the bst.cc code: INSTRUCTIONS: 3. First, implement the BST (declared in bst.h) and use the unittest_bst() function to test it. DO NOT CHANGE THIS CODE FOR YOUR SUBMISSION, as it will be used to test your code against the answers (with different seed values). 4. Implement the DB and use the unittest_db() function to test it. DO NOT CHANGE THIS CODE FOR YOUR SUBMISSION, as it will be used to test your code against the answers (with different input files). a) The student ID should be the base class's key member. b) The student ID should be automatically assigned such that the ID/key should be n if the student is the nth student to join the school. If the student later leaves (i.e., deleted from the BST), the ID does NOT get reassigned to another student. Thus, the student ID of the last student to join the school should reflect the TOTAL number of students that have joined this school since its reception (regardless of whether some have left). 5. Test your code against the provided input and output files. a) The provided answer for the BST unit test is in "unittest_ans_t100_s100.txt". The s100 refers to the seed of 100 (-s 100), and t100 refers to the number of elements to add to the BST (-t 100). b) The provided answer for the DB is in "students_1_ans.txt" for the "students_1.txt" input file. 6. Make sure your code has no memory leaks (using valgrind). 7. Your code should work beyond the provided unit tests. That is, even if it does work for all the given tests, if the code has an identifiable bug (i.e., by reading the source code), points WILL be deducted. For example, if I were to change unittest_bst(num_test, seed, cout, 5); -> unittest_bst(num_test, seed, cout, 100); it should still work. BST.H #ifndef BST_H_
  • 2. #define BST_H_ #include <iostream> using namespace std; class Node { private: int key; Node* parent; Node* left; Node* right; public: // Default constructor Node(); // Constructor Node(int in); // Destructor // a virtual constructor is required for inheritance virtual ~Node(); // Add to parent of current node void add_parent(Node* in); // Add to left of current node void add_left(Node* in); // Add to right of current node void add_right(Node* in);
  • 3. // Get key int get_key(); // Get parent node Node* get_parent(); // Get left node Node* get_left(); // Get right node Node* get_right(); virtual void print_info(ostream& to); }; class BST { private: Node* root; // Walk the subtree from the given node void inorder_walk(Node* in, ostream& to); // Get the minimum node from the subtree of given node Node* get_min(Node* in); // Get the maximum node from the subtree of given node Node* get_max(Node* in); public: // Constructor and Destructor BST(); ~BST();
  • 4. // Modify tree void insert_node(Node* in); void delete_node(Node* out); // Find nodes in the tree Node* tree_min(); // minimum key value Node* tree_max(); // maximum key value Node* get_succ(Node* in); // successor for a given node Node* get_pred(Node* in); // predecessor for a given node void walk(ostream& to); // Traverse the tree from min to max recursively Node* tree_search(int search_key); }; #endif COMLPETE THIS PART, BST.CC #include "bst.h" // --------------------------------------- // Node class // Default constructor Node::Node() { // TODO: Implement this } // Constructor Node::Node(int in) { // TODO: Implement this
  • 5. } // Destructor Node::~Node() { // TODO: Implement this } // Add parent void Node::add_parent(Node* in) { // TODO: Implement this } // Add to left of current node void Node::add_left(Node* in) { // TODO: Implement this } // Add to right of current node void Node::add_right(Node* in) { // TODO: Implement this } // Get key int Node::get_key() { // TODO: Implement this } // Get parent node
  • 6. Node* Node::get_parent() { // TODO: Implement this } // Get left node Node* Node::get_left() { // TODO: Implement this } // Get right node Node* Node::get_right() { // TODO: Implement this } // Print the key to ostream to // Do not change this void Node::print_info(ostream& to) { to << key << endl; } // --------------------------------------- // ---------------------------------------
  • 7. // BST class // Walk the subtree from the given node void BST::inorder_walk(Node* in, ostream& to) { // TODO: Implement this } // Constructor BST::BST() { // TODO: Implement this } // Destructor BST::~BST() { // TODO: Implement this } // Insert a node to the subtree void BST::insert_node(Node* in) { // TODO: Implement this } // Delete a node to the subtree void BST::delete_node(Node* out)
  • 8. { // TODO: Implement this } // minimum key in the BST Node* BST::tree_min() { // TODO: Implement this } // maximum key in the BST Node* BST::tree_max() { // TODO: Implement this } // Get the minimum node from the subtree of given node Node* BST::get_min(Node* in) { // TODO: Implement this } // Get the maximum node from the subtree of given node Node* BST::get_max(Node* in) { // TODO: Implement this }
  • 9. // Get successor of the given node Node* BST::get_succ(Node* in) { // TODO: Implement this } // Get predecessor of the given node Node* BST::get_pred(Node* in) { // TODO: Implement this } // Walk the BST from min to max void BST::walk(ostream& to) { // TODO: Implement this } // Search the tree for a given key Node* BST::tree_search(int search_key) { // TODO: Implement this } // --------------------------------------- INPUT FILE: Noel Cummings 83 Kian Avery 86
  • 10. Eliana Knox 77 Paisley Peck 15 Michael Mcgrath 93 Makayla Dixon 35 Mara Singh 86 Aaliyah Arias 92 Hector Nicholson 49 Leo Holder 21 Dangelo Ball 62 Dario Kaufman 27 Brett Ho 90 Jamarcus Castro 59 Sheldon Burnett 63 Van Bautista 26 Gabriel Kelley 40 Kristin Walker 26 Stephany Figueroa 72 Carsen Mullen 36 Wendy Singh 11 Ava Carlson 68 Vaughn Boone 67 Grant Simpson 29 Urijah Oneal 82 Melissa Larson 30 Javier George 62 Roland Walters 23 Brooklyn Mcpherson 67 Cayden Mccarthy 35 Dixie Parrish 29 Jaslyn Hinton 2 Rory Hahn 22 Diamond Lawson 58 Jasper Franco 69 Kendal Wheeler 67 Odin Browning 93 Kenna Benson 56 Reese Walters 11 Thalia Tran 42 Chad Horton 29 Asher Cardenas 73 Angel Finley 21 Charlotte Gray 19 Delilah Hoover 84 Drew Mckenzie 37 Brandon Mahoney 98 Cristian Chandler 24
  • 11. Leonel Briggs 15 Gracie Buchanan 70