public bool varmi(int no) { int i = 0; bool var = false; for (i = 0; i < 20; i++) { HeapDugumu dugum = heapArray[i]; if (dugum.ogrenci.ogrenciNo == no) { var = true; break; } else { var = false; } } if (var == true) { return(true); } else { return(false); } }
public void MoveToDown(int index) { int largerChild; HeapDugumu top = heapArray[index]; while (index < currentSize / 2) { int leftChild = 2 * index + 1; int rightChild = leftChild + 1; //Find larger child if (rightChild < currentSize && heapArray[leftChild].BasariPuani < heapArray[rightChild].BasariPuani) { largerChild = rightChild; } else { largerChild = leftChild; } if (top.BasariPuani >= heapArray[largerChild].BasariPuani) { break; } heapArray[index] = heapArray[largerChild]; index = largerChild; } heapArray[index] = top; }
/* * public HeapDugumu EnUygunAday(Bolumler b) * { * return b.EnUygunMezun(); * } */ public ListBox BolumTumMmezunListele(Bolumler b, int dilTuru) { Heap tmpheap = hash.GetHeap(b.BolumId); int i = 0; for (i = 0; i < 20; i++) { HeapDugumu dugum = tmpheap.DugumVer(i); if (dugum == null) { break; } else if ((int)dugum.ogrenci.Ingilizce.Dil == dilTuru) { lstbxMezunlar.Items.Add(dugum.BasariPuani.ToString() + "" + dugum.ogrenci.ad + " " + dugum.ogrenci.ogrenciNo.ToString() + " " + dugum.ogrenci.BolumBilgi.bolumadi + " " + dugum.ogrenci.Ingilizce.Dil.ToString() + Environment.NewLine); } else if (dilTuru == 4) { lstbxMezunlar.Items.Add(dugum.BasariPuani.ToString() + "" + dugum.ogrenci.ad + " " + dugum.ogrenci.ogrenciNo.ToString() + " " + dugum.ogrenci.BolumBilgi.bolumadi + " " + dugum.ogrenci.Ingilizce.Dil.ToString() + Environment.NewLine); } } return(lstbxMezunlar); }
public HeapDugumu RemoveMax() // Remove maximum value HeapDugumu { HeapDugumu root = heapArray[0]; heapArray[0] = heapArray[--currentSize]; MoveToDown(0); return(root); }
public HeapDugumu RemoveMax() { HeapDugumu root = heapArray[0]; heapArray[0] = heapArray[--currentSize]; MoveToDown(0); return(root); }
public bool Insert(Ogrenci ogr) { if (currentSize == maxSize) { return(false); } HeapDugumu newHeapDugumu = new HeapDugumu(ogr); heapArray[currentSize] = newHeapDugumu; MoveToUp(currentSize++); return(true); }
public void MoveToUp(int index) { int parent = (index - 1) / 2; HeapDugumu bottom = heapArray[index]; while (index > 0 && heapArray[parent].BasariPuani < bottom.BasariPuani) { heapArray[index] = heapArray[parent]; index = parent; parent = (parent - 1) / 2; } heapArray[index] = bottom; }
public HeapDugumu DugumVer(int indis) { HeapDugumu root = heapArray[indis]; return(root); }
public HeapDugumu EnUygunEleman() { HeapDugumu root = heapArray[0]; return(root); }