Question 1 – Write class PE_SU25_Q1 (PE_SU25_Q1.java) using array structure
Used to manage data as shown above. The array includes:
Question 2 – Write class PE_SU25_Q2 (PE_SU25_Q2.java) including:
2.1 [1 point] Create a constructor and necessary attributes to manage the tree.
2.2 [2.5 points] Implement the insert method to insert a model into AVL_ModelTree.
Use the compareTime method to compare publication times to maintain AVL properties after insertion.
2.3 [0.5 points] Implement a method to traverse the tree in in-order.
2.4 [1 point] Implement a method to delete a model by its name:
Requirement: must maintain AVL properties after deleting a model.
3.1 [0.5 points] Create an instance of AVL_ModelTree and add models to the tree.
3.2 [0.25 points] Perform in-order traversal and print the list of models.
3.3 [0.25 points] Delete a model named "BERT", then perform in-order traversal again.
Important Notes:
Used to manage data as shown above. The array includes:
- [0.5 points] A model class containing: model name (string), month of publication (integer), and year of publication (integer). Then, write a method to compare the year with the publication year of another model.
- [1 point] Implement removeFirst and addLast methods to remove the first element and add a new one to the end of the array.
- [1 point] Write a method using quick sort to sort the array in ascending order by year of publication.
- [0.5 points] Write a main method to test your implementation.
Question 2 – Write class PE_SU25_Q2 (PE_SU25_Q2.java) including:
- [1 point] A model class containing: model name (string), month of publication (integer), and year of publication (integer). Write a compareTime method to compare the time (month and year combined) when the other model was published (e.g. 6/2018 is before 10/2018).
- Class AVL_ModelTree, implemented using linked list structure, is designed to store and manage data based on the time the models were published. This class is responsible for efficiently handling the following operations:
2.1 [1 point] Create a constructor and necessary attributes to manage the tree.
2.2 [2.5 points] Implement the insert method to insert a model into AVL_ModelTree.
Use the compareTime method to compare publication times to maintain AVL properties after insertion.
2.3 [0.5 points] Implement a method to traverse the tree in in-order.
2.4 [1 point] Implement a method to delete a model by its name:
- Write a method to search the model by name using in-order traversal.
- Implement a delete method using copying technique for AVL_ModelTree above (the key is still the publication time) to delete a model by name.
Requirement: must maintain AVL properties after deleting a model.
- Method to test your implementation with the following tasks:
3.1 [0.5 points] Create an instance of AVL_ModelTree and add models to the tree.
3.2 [0.25 points] Perform in-order traversal and print the list of models.
3.3 [0.25 points] Delete a model named "BERT", then perform in-order traversal again.
Important Notes:
- You must write and submit two separate files (PE_SU25_Q1.java and PE_SU25_Q2.java). If this requirement is not met, you will lose 1 point.
- Only Apache NetBeans IDE is allowed during the test.
hình được dịch cũng không chuẩn lắm
