Question: Expand the BST implementation we had in class, by implementing the following extra functions: 1) (20 points) write a function T next (TNode P) that

 Expand the BST implementation we had in class, by implementing the following extra functions: 1) (20 points) write a function T next (TNode

Expand the BST implementation we had in class, by implementing the following extra functions: 1) (20 points) write a function T next (TNode P) that returns the successor of the node that is pointed by P based on in-order traversal. 2) (20 points) Write a function void print_level (int level) that prints all the nodes at the input level. If the level does not exist, output a proper error message. 3) (30 points) write a function bool isBST(), which returns true if the current binary tree is a BST, and false otherwise. Note that: checking whether every node contains a value larger than its left child and smaller than its right child .... Does not work for all cases 15 4) (30 points) write a function T LCS(T& a, T& b) that returns the smallest common ancestor of two nodes in a BST. If the tree is empty, or if it has less than three nodes, it returns -1. For example the LCS(6,12) = 10 10 25 12 20 30 6 18 22 Expand the BST implementation we had in class, by implementing the following extra functions: 1) (20 points) write a function T next (TNode P) that returns the successor of the node that is pointed by P based on in-order traversal. 2) (20 points) Write a function void print_level (int level) that prints all the nodes at the input level. If the level does not exist, output a proper error message. 3) (30 points) write a function bool isBST(), which returns true if the current binary tree is a BST, and false otherwise. Note that: checking whether every node contains a value larger than its left child and smaller than its right child .... Does not work for all cases 15 4) (30 points) write a function T LCS(T& a, T& b) that returns the smallest common ancestor of two nodes in a BST. If the tree is empty, or if it has less than three nodes, it returns -1. For example the LCS(6,12) = 10 10 25 12 20 30 6 18 22

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!