CSD201_Fall-2023_HCM_Ca_2_1980.webp
Thanh Loan1

CSD201_Fall-2023_HCM_Ca_2_1980.webp

The BSTree class is a binary search tree of User objects. The variable id is the key of the tree,thus it must be unique. The following methods should be completed:
Void insert(xName, xAge,xld)- insert new User with name=xName, age=xAge, and color=xColor to the tree (age>0)
Void f1()- You do not need to edit this function. Your task is to complete the insert(...)function above only. Output in the file f1.txt must be the following:
Content of the file f1.txt:
(Α,50,8) (Β,10,2) (E,30,10) (C,4,5) (F,14,9) (H,34,11) (D,25,4) (G,7,6) (J,19,3) (1,20,7)
(B,10,2) (J,19,3) (D,25,4) (C,4,5) (G,7,6) (1,20,7) (A,50,8) (F,14,9) (E,30,10) (H,34,11)
Void f2(0)- Perform the post-order traversal from the root but display to file f2.txt nodes with age<25 only.
(Hint: Copy the function postOrder(...) to function postOrder2(...) and modify it.)Output in the file f2.txt must be the following:
Content of the file f2.txt:
(A,50,8) (B,10,2) (C,4,5) (D,25,4) (J,19,3) (G,7,6) (1,20,7) (E,30,10) (F,14,9) (H,34,11)
(J,19,3) (1,20,7) (G,7,6) (C,4,5) (B,10,2) (F,14,9)
Void f30) - add age of all nodes have only one child to 3 (age=age+3).(Hint: such nodes will have either left child or right child.)Output in the file f3.txt must be the following:
Content of the file f3.txt:
FUOVERFLOW.C
Chưa có bình luận nào.

Thông tin

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

Image metadata

Filename
CSD201_Fall-2023_HCM_Ca_2_1980.webp
File size
133.6 KB
Dimensions
1552px x 618px

Share this media

Back
Bên trên Bottom