public int[] Build(int[] arr) { //Last Non leaf index int startIndex = (arr.Length / 2) - 1; Heapifying h = new Heapifying(); for (int i = startIndex; i >= 0; i--) { h.PercolateDown(arr, i); } return(arr); }
public void DeleteElement(int[] arr, int i) { //Get the last element int lastElement = arr[arr.Length - 1]; //Replace the element to be deleted with the last element arr[i] = lastElement; //Update the size of heap //Heapify the array Heapifying h = new Heapifying(); h.PercolateDown(arr, i); }