void insert(String xDesert, int xStep, int xType) - check if xDesert.charAt(0)= 'B' then do nothing,
otherwise insert new Camel object with desert-xDesert, step-xStep, type-xType to the tree (step
✓ Kizspy, me and typis consent arbitrary, even negative values).
void f10) - 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) (Y,6,-7) (F,-6,7)
(F,-6,7) (E,2,5) (C,4,3) (Y,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 type>4
only. Hint: Copy the function preOrder (...) to function preOrder2(...) and modify it. Output in the
file f2.txt must be the following:
(C,8,2) (D,6,1) (F,2,-1) (1,1,7) (K-1,5) (1,3,9) (L,5,10) (M,4,6) (G,7,3) (E,9,4) (H,10,8)
(1,1,7) (K-1,5) (1,3,9) (1,5,10) (M,4,6) (H,10,8)
void f30) - Suppose p is the 3rd node when performing the pre-order traversal of the tree.
Calculate number of nodes in the sub-tree with root p and suppose this number is k, then set
p.info.type=k.
(C,8,2) (D,6,1) (E,9,4) (F,2,-1) (G,7,3) (H,10,8) (1,1,7) (1,3,9) (K-1,5) (L,5,10) (M,4,6)
(C,8,2) (D,6,1) (E,9,4) (F,2,6) (G,7,3) (H,10,8) (1,1,7) (1,3,9) (K,-1,5) (L,5,10) (M,4,6)
.
void f40)-Suppose p is the 2nd node having left-child when performing the post-order
traversal of the tree from the root. Rotate p to right. Output in the file f4.txt must be the
following:
(C,8,2) (D,6,1) (E,9,4) (F,2,-1) (G,7,3) (H,10,8) (1,1,7) (1,3,9) (K,-1,5) (L,5,10) (M,4,6)
(C,8,2) (D,6,1) (E,9,4) (F,2,-1) (G,7,3) (H,10,8) (1,1,7) (1,3,9) (K,-1,5) (M,4,6) (L,5,10)
Zoom
+ 70%
2
Close