(C,9,2000) (D,2,5000) (E,8,7000) (F,1,6000) (G,5,9000) (H,6,4000)
(C,9,2000) (G,5,9000) (E,8,7000) (F,1,6000) (D,2,5000) (H,6,4000)
• void f4()- Suppose the list contains at least 6 elements. Reverse last 4 elements. The content of the output file f4.txt must be the following:
(Hint: You only need to swap the data between nodes, not necessarily swap nodes.)
Content of the file f4.txt:
(C,7,6000) (D,12,5000) (E,6,1100) (F,5,4000) (1,4,3000) (J,3,2000) (K,2,1000)
(C,7,6000) (D,12,5000) (Ε,6,1100) (K,2,1000) (J,3,2000) (1,4,3000) (F,5,4000)
Question 2:(6 marks)
In this question you should complete some methods in BSTree.java file.
The class User with 3 data members: name, age, and id are given and you do not need to edit it.FLOW.COM
The BSTree class is a binary search tree of User objects. The variable id is the key of the tree,thus it must be unique. The following methods should be completed:
Void insert(xName, xAge,xld)- insert new User with name=xName, age=xAge, and color=xColor to the tree (age>0)
Void f1(0)- You do not need to edit this function. Your task is to complete the insert(...)
function above only. Output in the file f1.txt must be the following:
Content of the file f1.txt:
ERFLOW.O
(Α,50,8) (Β,10,2) (E,30,10) (C,4,5) (F,14,9) (H,34,11) (D,25,4) (G,7,6) (J,19,3) (1,20,7)
(B,10,2) (J,19,3) (D,25,4) (C,4,5) (G,7,6) (1,20,7) (A,50,8) (F,14,9) (E,30,10) (H,34,11)