Relative Content

Tag Archive for cquicksort

Quicksort not properly sorting the array in C

#include <stdio.h> void swap(int arr[], int a, int b) { int temp = arr[a]; arr[a] = arr[b]; arr[b] = temp; } void quick(int arr[], int low, int high) { if(low>=high) return; int p = high; int l = low; int r = high; while(l<r){ while(arr[l]<=arr[p] && l<r) l++; while(arr[r]>arr[p] && r>l) r–; swap(arr, l, r); […]