Beispiel #1
0
        public void MoveToDown(int index)
        {
            int       largerChild;
            HeapDugum top = heapArray[index];

            while (index < currentSize / 2)
            {
                int leftChild  = 2 * index + 1;
                int rightChild = leftChild + 1;
                if (rightChild < currentSize && heapArray[leftChild].elemanPuani < heapArray[rightChild].elemanPuani)
                {
                    largerChild = rightChild;
                }
                else
                {
                    largerChild = leftChild;
                }
                if (top.elemanPuani >= heapArray[largerChild].elemanPuani)
                {
                    break;
                }
                heapArray[index] = heapArray[largerChild];
                index            = largerChild;
            }
            heapArray[index] = top;
        }
Beispiel #2
0
        public HeapDugum RemoveMax()
        {
            HeapDugum root = heapArray[0];

            heapArray[0] = heapArray[--currentSize];
            MoveToDown(0);
            heapArray[currentSize] = null;
            return(root);
        }
Beispiel #3
0
        public void MoveToUp(int index)
        {
            int       parent = (index - 1) / 2;
            HeapDugum bottom = heapArray[index];

            while (index > 0 && (heapArray[parent].elemanPuani < bottom.elemanPuani))
            {
                heapArray[index] = heapArray[parent];
                index            = parent;
                parent           = (parent - 1) / 2;
            }
            heapArray[index] = bottom;
        }
Beispiel #4
0
        public bool Insert(Kisiler deger)
        {
            if (currentSize == maxSize)
            {
                return(false);
            }
            foreach (var item in BasvuruListele())
            {
                if (item.TCKimlik == deger.TCKimlik)
                {
                    return(false);
                }
            }
            HeapDugum newHeapDugumu = new HeapDugum(deger);

            heapArray[currentSize] = newHeapDugumu;
            MoveToUp(currentSize++);
            return(true);
        }