// tworzy kopiec z tablicy public static HeapInBinaryTree CreateHeap(int[] heap) { HeapInBinaryTree heapTree = new HeapInBinaryTree(); Node node = new Node(heap[0]); heapTree.root = node; // przypisanie roota BuildHelper(heap, 0, node); return(heapTree); }
static void Main(string[] args) { Console.WriteLine("Kopiec binany jako drzewo binarne"); int[] heap1 = { 23, 17, 14, 7, 13, 10, 1, 5, 6, 12 }; HeapInBinaryTree heapTree = HeapInBinaryTree.CreateHeap(heap1); heapTree.root.ShowPreOrder(); Console.ReadKey(); }