def f1(self, id, name, price) check if name start with = "G" or id >100 or price >100 then do nothing, otherwise insert new Product with Id = id, Name=name and Price = price to the tree.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)
(49, A, 50) (25, Β, 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)
def f2(self, x) - Perform in-order traversal from the root but display only the node having price smaller than given x value (x=30). Hint: Copy the function inVisit(...) to inVisit2(...) and modify it.Output in this case like that:
OUTPUT
(-1, Q, 17) (0, 1, 20) (11, D, 50) (17, J, 12) (25, B, 25) (30, Κ, 22) (36, E, 42) (42, L, 47) (49, A, 50) (55, M, 18)(61, F, 34) (66, N, 15) (74, C, 25) (81, 0, 0) (86, H, 35) (93, PG, 32)
(-1, Q, 17) (0, 1, 20) (17, J, 12) (25, Β, 25) (30, Κ, 22) (55, M, 18) (66, N, 15) (74, C, 25) (81, 0, 0)
2
>
Zoom
+ 100%
Close