2
def f3(self, x) - Perform in-order traversal from the root and delete by Copying from right child (selected right child) the first node having both 2 children and price smaller than given x value (x=30). Output in this case like that:
OUTPUT
(49, Α, 50) (25, B, 25) (11, D, 50) (0, 1, 20) (-1, Q, 17) (17, J, 12) (36, E, 42) (30, K, 22) (42, L, 47) (74, C, 25)(61, F, 34) (55, M, 18) (66, N, 15) (86, Η, 35) (81, 0, 0) (93, PG, 32)
(49, Α, 50) (30, Κ, 22) (11, D, 50) (0, 1, 20) (-1, Q, 17) (17, J, 12) (36, E, 42) (42, L, 47) (74, C, 25) (61, F, 34)(55, M, 18) (66, N, 15) (86, H, 35) (81, 0, 0) (93, PG, 32)
def f4(self, x) - Perform pre-order traversal from the root and find the first node p having right child and price smaller than given x value. Rotate p to left about its' right child. Output in this case like that:
OUTPUT
(49, A, 50) (25, B, 25) (74, C, 25) (11, D, 50) (36, E, 42) (61, F, 34) (86, H, 35) (0, 1, 20) (17, J,12) (30, Κ, 22) (42, L, 47) (55, M, 18) (66, N, 15) (81, 0, 0) (93, PG, 32) (-1, Q, 17)
>
Zoom
+ 100%
Close