Assuming the list contains at least 3 nodes, find the node satisfying that: the difference of LValue and RValue is the minimum (it also means that: |LValue - RValue | is the minimum).
Input: size = 4
Expected result:
MD033, Mirinda, 45, 320ml, 12.000
Question Q2:
The given file Q2.py already contains statements to implement a simple program using Binary Search Tree structure. You should write statements to the following functions:
f. f1(): How many leaf nodes with key>10 are there in the Binary Search Tree (BST).
Input: size = 10
Expected result:
4
g. f2(): Compute the BST's height, then insert a new node with key=height*height to the tree.
Input: size = 5
Expected result:
4
10
15
20
30
40
h. f3(): Find the minimum value in the tree.
Input: size = 15
Expected result:
3
i. f4(): Delete the node with maximum key in the tree.
Input: size = 5
Expected result:
10
15
20
30
40 (this node is deleted)
j. f5(): Compute the average value of all leaf nodes in the BST. (get one digit after the decimal point)
Input: size = 4
Expected result:
27.5
(when the tree contains four nodes, the leaf nodes are 15 and 40; so the average value of all leaf
nodes is 27.5)
+ 100%
Zoom
Close