(P,1,3) (N,3,6) (R,4,8) (F,7,4) (Q,8,7) (M,9,5)
void f2()-Perform pre-order traversal for the left branch of the BST, but display to file f2.txt nodes with color>4 only.
Hint: Copy the function preOrder(...) to function preOrder2(...) and modify it.
Output in the file f2.txt must be the following (line 1: Breadth first traversal, line 2: pre-order traversal)
(P,7,9) (D,4,3) (G,9,6) (H,2,5) (B,6,4) (L,1,8) (N,3,1)
(H,2,5) (L,1,8)
void f3() Perform a new traversal method to visit all nodes in the BST with the constraint: visit the nodes in the descending order of weight. Output in the file f3.txt must be the following:(T,8,-5) (M,7,2) (P,6,3) (R,5,9) (S,4,1) (1,2,5) (Υ,1,6)
2
void f4()-Print out internal nodes of the tree. Output in the file f4.txt must be the following: (line1: pre-order traversal, line 2: internal nodes (by pre-order traversal))(Α,6,5) (Β,2,7) (P,1,9) (C,3,-8) (F,4,2) (D,5,-3) (E,8,3) (6,7,4) (Q,9,1)
(A,6,5) (B,2,7) (C,3,-8) (F,4,2) (E,8,3)
+ 80%
Zoom
Activate Windows
Go to Settings to activate Windows. Close