PE_CSD_SP22_Demo_264.webp
kidhood

PE_CSD_SP22_Demo_264.webp

  • Media owner kidhood
  • Ngày thêm
Bài viết gốc: Chủ đề 'PE CSD SP22 Demo'
Question paper (build 07.05.20.19)
void f3()-Find the second node having rate<6 then change its' wing to 99. Output in the file f3.txt must be the following:
(C,8,6) (D,3,5) (E,9,2) (F,5,8) (G,9,7) (H,6,8) (1,7,3)
(C,8,6) (D,3,5) (E,9,2) (F,5,99) (G,9,7) (H,6,8) (1,7,3)
. void f4() - Sort from beginning to the first max rate ascendingly rate. The content of the output file f4.txt must be the following:
(C,1,2) (D, 10,3) (Ε,2,15) (F,11,6) (1,6,14) (J,11,15) (Κ,7,9)(C,1,2) (E,2,15) (D,10,3) (F,11,6) (1,6,14) (J,11,15) (K,7,9)
Question 2: (4 marks)
In this question you should complete some methods in BSTree.java file.
The class Bird with 3 data members: type, rate and wing is given and you do not need to edit it. The BSTree class is a binary search tree of Bird objects. The variable rate is the key of the tree, thus it must be unique.The following methods should be completed:
void insert(String xType, int xRate, int xWing) - check if xType.charAt(0) == 'B' then do nothing,otherwise insert new Bird object with type=xType, rate=xRate, wing=xWing to the tree (rate and wing 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:
(A,7,9) (C,4,3) (D,8,6) (Ε,2,5) (Y,6,-7) (F,-6,7)
(F,-6,7) (Ε,2,5) (C,4,3) (1,6,-7) (Α,7,9) (D,8,6)
.
void f2() - Perform breadth-first traversal from the root but display to file f2.txt nodes with
wing>4 only. Hint: Copy the function breadth(...) to function breadth2(...) and modify it. Output
in the file f2.txt must be the following:
(C,8,2) (D,6,1) (Ε,9,4) (F,2,3) (6,7,8) (Η,1,7) (1,3,9) (1,5,5) (Κ,4,6)
(G,7,8) (H,1,7) (1,3,9) (1,5,5) (Κ,4,6)
X
Zoom
100%
Close
Chưa có bình luận nào.

Thông tin

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

Image metadata

Filename
PE_CSD_SP22_Demo_264.webp
File size
119.4 KB
Dimensions
1914px x 1030px

Share this media

Back
Bên trên Bottom