This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MaxHeap<T> where T: System.IComparable<T> | |
{ | |
public List<T> heapList {get; set;} | |
public int Count {get => heapList.Count;} | |
private int GetLeftChildIndex(int elementIndex) => 2 * elementIndex + 1; | |
private int GetRightChildIndex(int elementIndex) => 2 * elementIndex + 2; | |
private int GetParentIndex(int elementIndex) => (elementIndex - 1) / 2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MinHeap<T> where T: System.IComparable<T> | |
{ | |
public List<T> heapList {get; set;} | |
public int Count {get => heapList.Count;} | |
private int GetLeftChildIndex(int elementIndex) => 2 * elementIndex + 1; | |
private int GetRightChildIndex(int elementIndex) => 2 * elementIndex + 2; | |
private int GetParentIndex(int elementIndex) => (elementIndex - 1) / 2; |