diff --git a/KSenior2608/quick_sort_on_doubly_linked_list.cpp b/KSenior2608/quick_sort_on_doubly_linked_list.cpp new file mode 100644 index 0000000..4331f07 --- /dev/null +++ b/KSenior2608/quick_sort_on_doubly_linked_list.cpp @@ -0,0 +1,28 @@ + +int partition (int arr[], int l, int h) +{ + int x = arr[h]; + int i = (l - 1); + + for (int j = l; j <= h- 1; j++) + { + if (arr[j] <= x) + { + i++; + swap (&arr[i], &arr[j]); + } + } + swap (&arr[i + 1], &arr[h]); + return (i + 1); +} + + +void quickSort(int A[], int l, int h) +{ + if (l < h) + { + int p = partition(A, l, h); /* Partitioning index */ + quickSort(A, l, p - 1); + quickSort(A, p + 1, h); + } +}