(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)
2
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. The expected output in the file f3.txt should be the following:(T,8,-5) (M,7,2) (P,6,3) (R,5,9) (S,4,1) (L,2,5) (Y,1,6)
void f4() - Print out internal nodes of the tree. The expected output in the file f4.txt should be the following: (line 1: pre-order traversal, line 2: internal nodes (by pre-order traversal))(A,6,5) (B,2,7) (P,1,9) (C,3,-8) (F,4,2) (D,5,-3) (E,8,3) (G,7,4) (Q,9,1)
(A,6,5) (B,2,7) (C,3,-8) (F,4,2) (E,8,3)
void f5()-How many leaf nodes are there in the BST? The expected output in the file f5.txt should be the following: (line 1: in-order traversal, line 2: the amount of leaf nodes)(L,1,5) (H,2,6) (Q,3,1) (D,4,3) (B,6,-4) (M,7,9) (6,9,-6)
4
Close
+ 91%
Zoom