Question: mplement the following function: def restore _ bst ( prefix _ lst ) The function is given a list prefix _ lst , which contains

mplement the following function:
def restore_bst(prefix_lst)
The function is given a list prefix_lst, which contains keys, given in an order
that resulted from a prefix traversal of a binary search tree.
When called, it creates and returns the binary search tree that when scanned in
prefix order, it would give prefix_lst.
For example, the call restore_bst([9,7,3,1,5,13,11,15]),
should create and return the following tree:
39
13
373
3
11
15
333
3135
Notes:
1.2.3.4. The runtime of this function should be linear.
Assume that prefix_lst contains integers.
Assume that there are no duplicate values in prefix_lst.
You may want to define a helper function.

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 Programming Questions!