CSD201_-_PE_-_SU_2024_2168.webp
C

CSD201_-_PE_-_SU_2024_2168.webp

  • Media owner Carla89
  • Ngày thêm
void f3() - Suppose in the list there is only one element having place = E and one element having place G. Swap the positions of these two elements.. 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)
(C,7,6) (D,6,7) (G,8,7) (F,7,9) (E,3,8) (Η,4,9) (1,8,3)
void f4() - Suppose in the list there is only one element p having place = I. Sort all ements before p ascendingly by type. 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)(F,1,2) (E,8,7) (C,9,8) (D,11,12) (1,7,9) (J,6,8) (K,5,6) (L,9,8) (M,3,4)
Question 2: (4 marks)
In this question you should complete some methods in BSTree.java file.
The class Brick with 3 data members: place, price and type is given and you do not need to edit it. The BSTree class is a binary search tree of Brick objects. The variable type is the key of the tree, thus it must be unique. The following methods should be completed:
void insert(String xPlace, int xPrice, int xType) - check if xPlace.charAt(0) == 'A' then do nothing,otherwise insert new Brick object with place=xPlace, price=xPrice, type=xType to the tree (priceand 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:
(B,9,4) (C,4,3) (D,8,6) (Y,6,-7) (E,2,5) (F,-6,7)
(Y,6,-7) (C,4,3) (B,9,4) (E,2,5) (D,8,6) (F,-6,7)
void f2() - Perform pre-order traversal from the root but display to file f2.txt non-leaf nodes only.
Hint: Copy the function preOrder(...) to function preOrder2(...) and modify it. Output in the file
int be the fallaμίααι
+ 100%
Zoom
Close
Chưa có bình luận nào.

Thông tin

Category
CSD201
Thêm bởi
Carla89
Ngày thêm
Lượt xem
5,496
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
CSD201_-_PE_-_SU_2024_2168.webp
File size
306.5 KB
Dimensions
1920px x 1001px

Share this media

Back
Bên trên Bottom