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 restorebstprefixlst
The function is given a list prefixlst 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 prefixlst
For example, the call restorebst
should create and return the following tree:
Notes:
The runtime of this function should be linear.
Assume that prefixlst contains integers.
Assume that there are no duplicate values in prefixlst
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
