Kizspy.me
The BSTree class is a binary search tree of Movie objects. The tree uses the
Rating (an integer between 0 and 100) as the key for comparisons and
ordering. You are required to implement the following methods:
def f1(self, Title, Director, Rating):
Insert a new movie only if the following conditions are satisfied:
。 title must not start with the letter "X".
。 director must not contain the character "Z".
。 rating must be an int number in range 0 and 100 (0 <= rating <= 100).
If any of the above conditions are violated, do nothing. Otherwise, insert the new
movie into the BST according to rating. Output in this case like that:
OUTPUT
(D, R, 50) (C, A, 25) (E, H, 12) (P, E, 6) (Z, T, 18) (A, H, 37) (C, C, 32) (1, Y, 44) (F, B, 75)
(R, HQ, 62) (P, C, 56) (E, T, 68) (U, PM, 87) (CW, Q1, 81)
(D, R, 50) (C, A, 25) (F, B, 75) (E, H, 12) (A, H, 37) (R, HQ, 62) (U, PM, 87) (P, E, 6) (Z,
T, 18) (C, C, 32) (I, Y, 44) (P, C, 56) (E, T, 68) (CW, Q1, 81)
•
def f2(self, x) - Perform post-order traversal of the BST but display only
movies with a rating greater than x (x=40). Hint: Copy the function
PostVisit(...) to PostVisit2(...) and modify it. Output in this case like that:
OUTPUT
Zoom
(P, E, 6) (Z, T, 18) (E, H, 12) (C, Y, 32) (P, C, 44) (A, H, 37) (C, A, 25) (I, C, 56) (E, T, 68)
(R, HQ, 62) (CW, Q1, 81) (U, PM, 87) (F, B, 75) (D, R, 50)
+100%
67127
Close