void f1(self, name, age, salary) - check if name start with = "Y" or age <0 or salary <=0 then do nothing, otherwise insert new Employee with Name=name, Age = age and Salary =salary to the tree. Output in this case like that:
OUTPUT
(AY, 35, 35) (F, 25, 25) (H, 20, 20) (HQ, 18, 18) (Q1, 10, 10) (P, 21, 21) (Η, 31, 31) (Ε, 28, 28) (C, 32, 32) (Β,45, 45) (D, 40, 40) (T, 39, 39) (C, 50, 50) (E, 52, 52) (Τ, 60, 60)
(AY, 35, 35) (F, 25, 25) (B, 45, 45) (H, 20, 20) (H, 31, 31) (D, 40, 40) (C, 50, 50) (HQ, 18, 18) (P, 21, 21) (Ε,28, 28) (C, 32, 32) (Τ, 39, 39) (Ε, 52, 52) (Q1, 10, 10) (Τ, 60, 60)
void f2(self) - Perform post-order traversal from the root but display only the node having age is an even number and salary > 20. Hint: Copy the function postVisit(...) to postVisit2(...) and modify it. Output in this case like that:
OUTPUT
(Q1, 10, 10) (HQ, 18, 18) (P, 21, 21) (Η, 20, 20) (Ε, 28, 28) (C, 32, 32) (H, 31, 31) (F, 25, 25) (T, 39, 39) (D,40, 40) (Τ, 60, 60) (E, 52, 52) (C, 50, 50) (B, 45, 45) (ΑΥ, 35, 35)
(Ε, 28, 28) (C, 32, 32) (D, 40, 40) (Τ, 60, 60) (E, 52, 52) (C, 50, 50)
Zoom
100%
Close