Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>QuickSort Algorithm: - QuickSort( A[], l, r) - P = A[l] // Select pivot as the beginning element from array or you can do better //with good pivots. - i = l + 1 // index i to be next of pivot - for j = l + 1 to r - if A[j] &lt; P - swap (A[j], A[i]) - increment i - end if - end for - swap (A[i-1], A[l]); -- Call recursive on left partitioned array -- Call recursive on right partitioned array. // QuickSort_2.cpp : Defines the entry point for the console application. // #include "stdafx.h" #define ARR_SIZE 200 #define PR_ARR_SIZE 200 unsigned int input_arr[ARR_SIZE]; void swap(unsigned int *a, unsigned int *b) { unsigned int tmp; tmp = *a; *a = *b; *b = tmp; } void print_input(unsigned int input[], unsigned int l, unsigned int n) { unsigned int i; for (i = l; i &lt; n; i++) printf("%d ", input[i]); printf("\n"); } void QuickSort(unsigned int input[], unsigned int l, unsigned int r) { unsigned int i = l + 1, j; unsigned int pivot = input[l]; if (l + 1 &lt; r) { for (j = l + 1; j &lt; r; j++) { if (input[j] &lt; pivot) { swap(&amp;input[j], &amp;input[i]); i++; } } swap(&amp;input[i - 1], &amp;input[l]); QuickSort(input, l, i); QuickSort(input, i, r); } } int _tmain(int argc, _TCHAR* argv[]) { unsigned int i = 0; unsigned int val; FILE *fp; errno_t err = fopen_s(&amp;fp, "IntegerArray.txt", "r+"); if (err) { printf("unable to open a file\n"); return -1; } while (fscanf_s(fp, "%ld\n", &amp;val) != EOF) { input_arr[n++] = val; } print_input(input_arr, 0, n); QuickSort(input_arr, 0, n); print_input(input_arr, 0, n); return 0; } Put these values in "IntegerArray.txt" file and 2 3 4 5 6 10 11 12 1 17 18 19 20 7 8 9 13 14 15 16 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload