From e2157e7093cfcc2dfaacabe880e35b76c712b6bf Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 4 Nov 2022 11:28:52 +0000 Subject: [PATCH] Updated Heap to allow Heap Creation (Not fully implemented) --- C#/Datastructures/Heap/Heap.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/C#/Datastructures/Heap/Heap.cs b/C#/Datastructures/Heap/Heap.cs index 9d6738d..23254b2 100644 --- a/C#/Datastructures/Heap/Heap.cs +++ b/C#/Datastructures/Heap/Heap.cs @@ -23,5 +23,22 @@ namespace C_.Datastructures.Heap 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; + } + } } } \ No newline at end of file