Question: coding must be done in c# Question 4: Binary Heaps (19 marks) a) (2 marks) Draw the binary heap that corresponds to the array below

coding must be done in c#coding must be done in c# Question 4: Binary Heaps (19 marks)

Question 4: Binary Heaps (19 marks) a) (2 marks) Draw the binary heap that corresponds to the array below 10 | 20 | 80 | 30 | 50 | 100 | 90 | 70 | 40 | 60 4 10 b) (2 mark) Identify the values with the highest and lowest priorities in the binary heap. c) (6 marks) lustrate (without code) how to remove the value with the lowest priority from the binary heap above. Keep in mind the two properties of a binary heap d) (9 marks, optional) Consider the (partial) definition of PriorityQueue implemented below using a binary heap class PriorityQueueT> where T IComparable private T]A; II The binary heap private int size; II The number of values in the binary heap I/ Percolates up beginning at index j private void PercolateUp (int j) I/ Percolates down beginning at index j private void PercolateDown (int j) Il Removes and returns the value at indexj public T Delete (int j) Suppose the method Delete method is redefined to remove and return not only the root value at index 1, but any value in the binary heap at a given index j. Using the methods PercolateUp and/or PercolateDown, implement the new method Delete. Remember that T is defined for the method CompareTo. Question 4: Binary Heaps (19 marks) a) (2 marks) Draw the binary heap that corresponds to the array below 10 | 20 | 80 | 30 | 50 | 100 | 90 | 70 | 40 | 60 4 10 b) (2 mark) Identify the values with the highest and lowest priorities in the binary heap. c) (6 marks) lustrate (without code) how to remove the value with the lowest priority from the binary heap above. Keep in mind the two properties of a binary heap d) (9 marks, optional) Consider the (partial) definition of PriorityQueue implemented below using a binary heap class PriorityQueueT> where T IComparable private T]A; II The binary heap private int size; II The number of values in the binary heap I/ Percolates up beginning at index j private void PercolateUp (int j) I/ Percolates down beginning at index j private void PercolateDown (int j) Il Removes and returns the value at indexj public T Delete (int j) Suppose the method Delete method is redefined to remove and return not only the root value at index 1, but any value in the binary heap at a given index j. Using the methods PercolateUp and/or PercolateDown, implement the new method Delete. Remember that T is defined for the method CompareTo

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!