using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace C_.Datastructures.Heap { internal class Heap where T:IComparable { internal HeapNode? Root { get; set; } private int Count { get; set; } public static Heap Create(){ return new Heap{ Root = null, Count = 0 }; } public static Heap Create(T value){ return new Heap{ Root = HeapNode.Create(value), Count = 1 }; } public void Add(T value){ Count++; if (Root == default) {//If the new node needs to be added to the top of the heap Root = HeapNode.Create(value); return; } //If the new node can be placed in a subchild HeapNode node = Root; while(node.Left != default){ node = node.Left; } } } }