Question: Question 2 Suppose that you are given n different atoms of different masses and a new atom is obtained by fusing two atoms. You want

 Question 2 Suppose that you are given n different atoms of

Question 2 Suppose that you are given n different atoms of different masses and a new atom is obtained by fusing two atoms. You want to fuse all of the atoms into one atom. Suppose that the energy gained by fusing two atoms is equal to the total mass of the fused atoms. We aim to obtain maximum energy by fusing the atoms into a single one. For example if we are given 4 atoms of masses 4, 5, 8 and 2, the optimum solution that gives the maximum energy gain is: a) Fuse atoms of masses 8 and 5 first. Now we have three atoms with masses 4, 13 and 2. Energy gain from this step is 8 + 5 = 13. b) Now we have atoms with masses 4, 13 and 2. Fuse atoms of masses 13 and 4. The masses of the resulting atoms are 17 and 2. Energy gain from this step is 13+ 4 = 17. c) Fuse the remaining two atoms with masses 17 and 2. Energy gain from this step is 17 + 2 = 19. The energy gain from the above-given optimal solution is 13 + 17 + 19 = 49. d) Design a greedy solution for the above-given problem that finds the maximum energy that can be gained for any given input. Use heap data structure to design your algorithm. If you do not use heap, you will not get any credits. e) Apply the algorithm you have designed to the below-given input which represents the array containing the masses of the atoms. Show each step and heap status for each iteration clearly to get credits. A=[10, 4, 8, 2, 20]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!