Note that this is the 2nd part of the BINARY SEARCH TREE problem Get the ordered
ID: 3611794 • Letter: N
Question
Note that this is the 2nd part of the BINARY SEARCH TREE problem Get the ordered sequence of a binary search tree (by the inorder traversal) Input file: this is a binary search tree a binary search tree is efficient for search After we formed a BST like this one: Output example: (a 2) (binary 2) (efficient 1) (for 1) (is 2) (search 3) (this 1) (tree 2) Hint: recursively call printSubTree() function How can you get the ordered sequence from a binary search tree? By the inorder traversal How can you implement it? Recursive function The key is to find what repeats The traversal is always based on the order left, center (output), and right You can get the repeated part of the recursive function Pseudo code for printSubTree() void printSubTree(Node* root) { if(root->leftChild ! = NULL) { printSubTree(root->leftChild); } print your data if(root->rightChild != NULL) { printSubTree(root->rightChild); } }Explanation / Answer
Note that this is the 2nd part of the BINARY SEARCH TREE problem Get the ordered
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.