Min Heap of Candy — Add and Remove
Min Heap of Candy — Add and Remove
Using the provided code (Question04.java and Candyjava), write the add and remove methods for a min heap of Candy using an array implementation. Make sure to include all provided files in your project and write your solution in the file "Question04.java". This method should preserve the properties of a min hap, and the candies are compared based on their weight. This value can be accessed through its accessor.
Solution Tests:
• Does the solution compile?
• Does the solution have your name in the comments?
• Does the solution have a high-level solution description (150-300 words) in the comments?
• Does the method preserve the properties of a Min Heap?
• Does the output match the following?
Testing the Add Method
Candy Weight: 10.0,
Candy Weight: 40.0,
Candy Weight: 20.0,
Candy Weight: 50.0,
Candy Weight: 60.0,
Candy Weight: 80.0,
Candy Weight: 30.0,
Candy Weight: 100.0,
Candy Weight: 70.0,
Candy Weight: 90.0,
Testing the Remove Method
Candy Weight: 10.0,
Candy Weight: 20.0,
Candy Weight: 30.0,
Candy Weight: 40.0,
Candy Weight: 50.0,
Candy Weight: 60.0,
Candy Weight: 70.0,
Candy Weight: 80.0,
Candy Weight: 90.0,
Candy Weight: 100.0,
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images