void insert(String xPlace, int xWeight, int xColor) - The variable weight is the key of the tree, thus it must be unique. The new node is inserted to the binary search tree.
void f1() - Your task is to add statements in the insert(...) method so that any node with xPlace.charAt(0) == 'B' is not inserted to the tree. The output in file f1.txt should be as follows:(line 1: Breadth first traversal, line 2: In-order traversal)
(A,6,2) (C,3,4) (D,9,-2) (Ε,1,3) (F,4,7) (G,8,-1)
(Ε,1,3) (C,3,4) (F,4,7) (A,6,2) (G,8,-1) (D,9,-2)
void f2() - Perform pre-order traversal from the root but display to file f2.txt nodes with color>3 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 (with color>3))
(N,5,-2) (C,3,9) (Q,8,5) (G,1,4) (Τ,7,6) (Κ,9,1) (Υ,2,7)
10201 IC 1 NIN211 ㅇㄷ)/T7C1
FUO
Close
+ 150%
Zoom