☑Kizspy.me
.
void f3()- Suppose p is the first node having maximum step in the list. Find the second node q
having q.info.step<p.info.step. Swap the contents of p and q. Output in the file f3.txt must be the
following:
(C,7,6) (D,6,7) (E,3,8) (F,7,9) (G,8,7) (H,4,9) (1,8,3) (J,5,4)
(C,7,6) (G,8,7) (E,3,8) (F,7,9) (D,6,7) (H,4,9) (1,8,3) (J,5,4)
void f4()- Find the element p having desert = F. Reverse all elements after p. The content of the
output file f4.txt must be the following:
(C,9,8) (D,11,12) (E,8,7) (F,1,2) (1,7,9) (J,6,8) (K,5,6) (L,9,8) (M,3,4)
(C,9,8) (D,11,12) (E,8,7) (F,1,2) (M,3,4) (L,9,8) (K,5,6) (J,6,8) (1,7,9)
Question 2: (4 marks)
In this question you should complete some methods in BSTree.java file.
The class Camel with 3 data members: desert, step and type is given and you do not need to edit it. The
BSTree class is a binary search tree of Camel objects. The variable step is the key of the tree, thus it must
be unique. The following methods should be completed:
• 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
and type can get arbitrary, even negative values).
Zoom
+ 100%
Close