CSD201_-_PE_-_SU_2025_-_Block_1_3995.webp
G

CSD201_-_PE_-_SU_2025_-_Block_1_3995.webp

☑Kizspy.me
void f3() - Suppose p is the first node having place=E, and p.info.wing-k. Remove all elements
having wing<k. 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)
(E,3,8) (F,7,9) (H,4,9)
. void f4() Find the node p having place = E and node q having place-K. Sort all elements from p
to q ascendingly by wing. 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) (F,1,2) (K,5,6) (E,8,7) (J,6,8) (1,7,9) (L,9,8) (M,3,4)
Question 2: (4 marks)
In this question you should complete some methods in BSTree.java file.
The class Canary with 3 data members: place, song and wing is given and you do not need to edit it. The
BSTree class is a binary search tree of Canary objects. The variable wing is the key of the tree, thus it
must be unique. The following methods should be completed:

void insert(String xPlace, int xSong, int xWing) - check if xPlace.charAt(0) == 'A' then do nothing,
otherwise insert new Canary object with place-xPlace, song-xSong, wing-xWing to the tree (song
and wing can get arbitrary, even negative values).

void f10) 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 post-order traversal from the root but display to file f2.txt nodes with song<7
only. Hint: Copy the function postOrder (...) to function postOrder2(...) and modify it. Output in
the file f2.txt must be the following:
(F.2.-1) (D.6.1) (G.7.3) (M.4.6) (K.-1.5) (1.1.7) (1.5.10) (1.3.9) (H.10.8) (E.9.4) (C.8.2)
Zoom
+ 102%
Close
Chưa có bình luận nào.

Thông tin

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

Share this media

Back
Bên trên Bottom