DAS  3.1.6 - 18/09/2017
Functions
quick.c File Reference
#include <stdlib.h>
#include <stdio.h>
+ Include dependency graph for quick.c:

Go to the source code of this file.

Functions

void q_sort (double numbers[], int left, int right)
 
void quickSort (double numbers[], int array_size)
 

Function Documentation

§ q_sort()

void q_sort ( double  numbers[],
int  left,
int  right 
)

Definition at line 61 of file quick.c.

Referenced by quickSort().

62 {
63  int pivot;
64  double l_hold, r_hold;
65 
66  l_hold = left;
67  r_hold = right;
68  pivot = (int) numbers[left];
69  while (left < right)
70  {
71  while ((numbers[right] >= pivot) && (left < right))
72  right--;
73  if (left != right)
74  {
75  numbers[left] = numbers[right];
76  left++;
77  }
78  while ((numbers[left] <= pivot) && (left < right))
79  left++;
80  if (left != right)
81  {
82  numbers[right] = numbers[left];
83  right--;
84  }
85  }
86  numbers[left] = pivot;
87  pivot = left;
88  left = (int) l_hold;
89  right = (int) r_hold;
90  if (left < pivot)
91  q_sort(numbers, left, pivot-1);
92  if (right > pivot)
93  q_sort(numbers, pivot+1, right);
94 }
void q_sort(double numbers[], int left, int right)
Definition: quick.c:61
+ Here is the caller graph for this function:

§ quickSort()

void quickSort ( double  numbers[],
int  array_size 
)

Definition at line 54 of file quick.c.

References q_sort().

55 {
56  q_sort(numbers, 0, array_size - 1);
57 }
void q_sort(double numbers[], int left, int right)
Definition: quick.c:61
+ Here is the call graph for this function:
______________________________________________________________________________________
Generated on Mon Sep 18 2017 11:46:40 for DAS - Rel. 3.1.6 - 18/09/2017.