☑Kizspy.me
be unique. The following methods should be completed:
.•
void insert(String xOwner, int xColor, int xSize) - check if xOwner.charAt(0) == 'B' then do nothing,
otherwise insert new Brick with owner=xOwner, color=xColor, size=xSize to the tree (color and
size can get arbitrary, even negative values).
void f1() - Do not edit this method. Your task is to complete the insert(...) method above only.
Output in the file f1.txt must be the following:
(A,7,9) (C,4,3) (D,8,6) (E,2,5) (F,6,7)
(E,2,5) (C,4,3) (F,6,7) (A,7,9) (D,8,6)
. void f2()-Perform pre-order traversal from the root but display to file f2.txt nodes with size<7
only. Hint: Copy the function preOrder(...) to function preOrder2(...) and modify it. Output in the
file f2.txt must be the following:
(C,3,6) (E,2,8) (D,7,2) (F,4,5) (H,6,3) (1,5,4) (G,8,7)
(C,3,6) (D,7,2) (F,4,5) (H,6,3) (1,5,4)
•
void f30) Perform breadth-first traversal and find the first node p having color<6, then delete
the node p by copying. Output in the file f3.txt must be the following:
(C,6,3) (D,3,2) (E,7,6) (F,2,4) (G,5,7) (H,4,5)
(C,6,3) (F,2,4) (E,7,6) (G,5,7) (H,4,5)
Zoom
+100%
Close