CSD203_-_FA_2024_-_PE_2872.webp
F

CSD203_-_FA_2024_-_PE_2872.webp

def f4(self) - Sort price in descending order of all Products whose Id is an odd number, if the price of Products is same price, then sort name in ascending order. The other elements are unchanged.
Output in this case like that:
OUTPUT
(-1, A, 5) (31, B, 23) (42, DE, 23) (45, E, 52) (21, F, 23) (18, H, 30) (31, XH, 23) (41, ZX, 5) (11, P, 23) (14,EC, 23)
(45, Ε, 52) (31, B, 23) (42, DE, 23) (21, F, 23) (11, P, 23) (18, H, 30) (31, XH, 23) (-1, A, 5) (41, ZX, 5) (14,EC, 23)
Question 2: (4 marks)
In this question you should complete some methods in BSTree.py files.
The class Product with 3 data members: Id, Name and Price is given and you do not need to edit it. The BSTree class is a binary search tree of Product objects. The variable Id is the key of the tree. The following methods should be completed:
def f1(self, id, name, price) check if name start with = "G" or id >100 or price >100 then do nothing, otherwise insert new Product with Id = id, Name=name and Price = price to the tree.Output in this case like that:
OUTPUT
(49. Α. 50) (25. B. 25) (74. С. 25) (11. D. 50) (36. Ε. 42) (61. F. 34) (86. H. 35) (0. Ι. 20) (17. J. 12) (30. Κ. 22)
Close
+ 100%
Zoom
Chưa có bình luận nào.

Thông tin

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

Image metadata

Filename
CSD203_-_FA_2024_-_PE_2872.webp
File size
215.5 KB
Dimensions
1920px x 813px

Share this media

Back
Bên trên Bottom