unique. The following methods should be completed:
void insert(String xType, int xRate, int xWing) - check if xType.charAt(0) == 'B' then do nothing,otherwise insert new Bird object with type=xType, rate=xRate, wing=xWing to the tree (rate and wing 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:(B,9,4) (C,4,3) (D,8,6) (Y,6,-7) (E,2,5) (F,-6,7)
(Y,6,-7) (C,4,3) (B,9,4) (E,2,5) (D,8,6) (F,-6,7)
void f2()-Perform breadth-first traversal from the root but display to file f2.txt nodes with rate>4 only. Hint: Copy the function breadth(...) to function breadth2(...) and modify it. Output in the file f2.txt must be the following:
(C,8,2) (D,6,1) (E,9,4) (F,2,3) (G,7,8) (H,1,7) (1,3,9) (J,5,5) (Κ,4,6)
(C,8,2) (D,6,1) (E,9,4) (G,7,8) (J,5,5)
void f3() - Suppose p is the 4-th node when performing the post-order traversal of the tree and f is the father of p. Delete the node f by copying. Output in the file f3.txt must be the following:(D,6,1) (F,2,3) (Κ,4,6) (J,5,5) (H,1,7) (1,3,9) (G,7,8) (E,9,4) (C,8,2)
(D,6,1) (F,2,3) (K,4,6) (J,5,5) (1,3,9) (G,7,8) (E,9,4) (C,8,2)
Zoom
Close
100%