Bir bog‘lamli ro‘yxatlar ustida amallar va ularning algoritmlari
Download 358.29 Kb.
|
singlyLinkedList *getTail(singlyLinkedList *cur)
{ while (cur != NULL && cur->next != NULL) cur = cur->next; return cur; } // quick sort uchun tayanch elementni qaytaruvchi metod singlyLinkedList *pivotion(singlyLinkedList *head, singlyLinkedList *end, singlyLinkedList **newHead, singlyLinkedList **newEnd) { singlyLinkedList *pivot = end; singlyLinkedList *prev = NULL, *cur = head, *tail = pivot; while (cur != pivot) { if (cur->data < pivot->data) {
singlyLinkedList *list = NULL; for (int i = 0; i < 10; i++) pushList(&list, rand() % 100); cout << "\n Bir bog'lamli ro'yhatning dastlabki randomda kiritilgan elementlari:\n\n"; showList(list); quickSort(&list); cout << "\n Bir bog'lamli ro'yhatni quick sort saralash algoritimi orqali saraladik:\n\n"; showList(list); system("Pause"); return 0; } Dastur natijasi: Bir bog'lamli ro'yhatning dastlabki randomda kiritilgan elementlari: 34, 31, 83, 95, 75, 95, 90, 11, 75, 21 Bir bog'lamli ro'yhatni quick sort saralash algoritimi orqali saraladik: 11, 21, 31, 34, 75, 75, 83, 90, 95, 95 Download 358.29 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling