. f5(): Let's define the 'value' of a node as follows: value = amount price. LValue and RValue of a node is the total value of nodes before and after that node (for example: if the list contain 7 nodes,and node K is the third node, so the LValue of K is the total value of two first nodes, and the RValue of K is the total value of the four last nodes).
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:
+ 100%
Zoom
Close