Question: 3. In a binary search tree, we might also keep track of the total number of nodes in that subtree (including the node itself). a.

3. In a binary search tree, we might also keep track of the total number of nodes in that subtree (including the node itself). a. Assuming we store this value (e.g. x.size) write pseudocode for a function BSTKeyLessThan(T, k) that takes a tree T and a number k and returns the number of values in the tree T that are less than k. For example, if the tree had the number 1 through 9 in it, then BSTKeyLessThan(T, 5) should return 4. What is the best-case and worst-case running time of your algorithm? b. Describe an algorithm Median (T) that finds the median element in a binary search tree. Write pseudocode or state your algorithm precisely. State your run-time with respect to the height of the tree
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
