Question 3: (35 Marks) Given three groups of mugs A, B, and C of n mugs each, where the shapes of the mugs are different
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Question 3: (35 Marks) Given three groups of mugs A, B, and C of n mugs each, where the shapes of the mugs are different
Question 3: (35 Marks) Given three groups of mugs A, B, and C of n mugs each, where the shapes of the mugs are different. Given a list of different amounts of tea are hold in the mugs of group A, and the same list is exactly repeated in-group B and C randomly. This means that the mug 1 in- group A of may not match with its corresponding mug in-group B or C that hold exactly the same amount of tea. Your mission is to find a way to match the mugs into triples from group A, B, and C that hold exactly the same amount of tea. For example: 4 7 Group A ABC 8 3 150 160 130 6 9 Input: Amount of tea in mille litter Group 1 2 3 140 150 200 130 140 90 1 Output: A[1] with B[3] with C[6] A[2] with B[6] with C[1] A[3] with B[2] with C[4] ... and so on 7 Group B 4 110 70 140 2 8 5 160 110 180 9 6 200 130 150 7 90 180 70 Group C 2 8 8 180 200 160 9 70 90 110 ٤/٣ a) Using a brute-force approach, design an algorithm to solve this problem (4 marks) b), and analyze its complexity (4 marks) c) Design a more efficient algorithm to solve this problem (8 marks), and analyze its complexity (4 marks) [Hint: you can use any data-structure] d) Implement your efficient algorithm using Python (10 marks) e) Prepare a brief report (250 words) comparing the two algorithms (5 marks) ●●