Question: do in c# if required to code otherwise answer Question 5: Binary Heaps (17 marks) Consider the binary heap below where smaller values have higher
do in c# if required to code otherwise answer
Question 5: Binary Heaps (17 marks) Consider the binary heap below where smaller values have higher priorities. 10 14 19 31 42 27 26 35 a) (2 marks) Show how to store this binary heap in an array, beginning at index 1 b) (1 mark) Which value in this binary heap has the lowest priority? c ( mark) In a binary heap, what kind of node stores the value with the lowest priority? d) (13 marks) Using the data members and methods of the BinaryHeap class given below, implement the method RemoveLowest which removes the value with the lowest priority Assume that CompareTo returns a negative integer if the current value has a lower priority than its parameter. Hint: Remember to satisfy the two properties of a binary heap class Binary Heap T> where T : IComparable private T[]A; private int size; the number of values in the bi nary heap private void PercolateUp(intj) { .. } // percolates up beginning at index j public T RemoveLowestO .. > Question 5: Binary Heaps (17 marks) Consider the binary heap below where smaller values have higher priorities. 10 14 19 31 42 27 26 35 a) (2 marks) Show how to store this binary heap in an array, beginning at index 1 b) (1 mark) Which value in this binary heap has the lowest priority? c ( mark) In a binary heap, what kind of node stores the value with the lowest priority? d) (13 marks) Using the data members and methods of the BinaryHeap class given below, implement the method RemoveLowest which removes the value with the lowest priority Assume that CompareTo returns a negative integer if the current value has a lower priority than its parameter. Hint: Remember to satisfy the two properties of a binary heap class Binary Heap T> where T : IComparable private T[]A; private int size; the number of values in the bi nary heap private void PercolateUp(intj) { .. } // percolates up beginning at index j public T RemoveLowestO .. >
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
