it. The MyList class is a linked list of Laptop objects. The following methods should be completed:
void addLast(String xProducer, int xWeight, int xPrice). (note: xWeight>3 and xPrice>3)
void f1() - Do not edit this method. Your task is to complete the addLast(...) method above only.Output in the file f1.txt must be the following:
(H,6,7) (C,4,5) (X,8,9) (1,5,8)
void f2() -There are 2 given Laptop objects v, w in this function. Suppose the list contains at least 2 element. Write statements to insert v and w to the first and the last position, respectively.Output in the file f2.txt must be the following:
(D,4,7) (L,10,5) (E,9,7) (Q,7,6)
(V,8,9) (D,4,7) (L,10,5) (E,9,7) (Q,7,6) (W,6,7)
1
void f3() - Delete the node holding the heaviest Laptop (maximum weight). If there are more than one node satisfying the requirement, delete the first of them. Output in the file f3.txt must be the following:
(A,4,4) (D,10,6) (E,9,4) (F,5,8) (Q,10,5) (R,5,7)
(Α,4,4) (E,9,4) (F,5,8) (Q,10,5) (R,5,7)
void f4()-How many Laptops are there in the list? The output in the f4.txt file should be as follows:(J,4,5) (K,5,6) (L,6,8)
3
void f5() - Delete the first two nodes, then sort the elements ascending by weight (assuming that:there is no duplicated value for weight). The content of the output file f5.txt must be the following:-(N,6,10) (Α,9,13) (W,5,8) (1,4,6) (S,7,5) (D,8,9)
(1,4,6) (W,5,8) (S,7,5) (D,8,9)
Question 2: (5 marks)
In this question you should complete some methods in BSTree.java file.
The class Cat with 3 data members: place, weight and color is given and you do not need to edit it. The
BSTree class is a binary search tree of Cat objects. The following methods should be completed:
void insert(String xPlace, int xWeight, int xColor) - The variable weight is the key of the BSTree,
Zoom
Close
+ 100%