Need help with C++, binary tree node, recursive linear-time function!! Thank you
ID: 3692866 • Letter: N
Question
Need help with C++, binary tree node, recursive linear-time function!! Thank you!!
--------------------------------------------------------------------------------------
Suppose that a node in a binary tree is represented as follows: struct Node { int key; struct Node *left, *right; // pointers to the left and right children };
Complete the code of a recursive function findDescendants below, which given a pointer to a
node in a binary tree, finds the keys of all the nodes that are descendants of this node. The
arguments of this function are as follows:
node is a pointer to an instance of struct Node for which the function finds descendants
descendants is a reference to a vector of integers that contains the keys of all descendants
void findDescendants(Node *node, std::vector &descendants) {
}
---------------------------------------------------------------------------------------
Plus I gave the links to my other 4 problems if you want to do those as well! Thank you!
https://www.chegg.com/homework-help/questions-and-answers/need-help-c-binary-tree-node-recursive-linear-time-function-thank-plus-gave-links-4-proble-q12397569
https://www.chegg.com/homework-help/questions-and-answers/need-help-c-binary-tree-node-recursive-linear-time-function-thank-plus-gave-links-4-proble-q12397691
https://www.chegg.com/homework-help/questions-and-answers/need-help-c-binary-tree-node-recursive-linear-time-function-thank-suppose-node-binary-tree-q12397779
https://www.chegg.com/homework-help/questions-and-answers/need-help-c-binary-tree-node-recursive-linear-time-function-thank-suppose-node-binary-tree-q12397829
Explanation / Answer
# include # include using namespace std; /* * Node Declaration */ struct node { int info; struct node *left; struct node *right; }*root; /* * Class Declaration */ class BST { public: void insert(node *, node *); void inorder(node *); void display(node *, int); BST() { root = NULL; } }; /* * Main Contains Menu */ int main() { int choice, num; BST bst; node *temp; while (1) { coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.