☑Kizspy.me
•
otherwise insert new Camel object with desert-xDesert, step-xStep, type-xType to the tree (step
and type 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) (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) (J,3,9) (L,5,10) (M,4,6) (G,7,3) (E,9,4) (H,10,8)
(1,1,7) (K,-1,5) (J,3,9) (L,5,10) (M,4,6) (H,10,8)
.
void f3() - 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) (J,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)
Zoom
+100%
Close