Click here to Skip to main content
15,888,461 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Sort Functions Pin
David Crow23-Nov-10 8:39
David Crow23-Nov-10 8:39 
GeneralRe: Sort Functions Pin
Babylon Lion23-Nov-10 10:11
Babylon Lion23-Nov-10 10:11 
GeneralRe: Sort Functions Pin
CurtainDog23-Nov-10 21:12
CurtainDog23-Nov-10 21:12 
AnswerRe: Sort Functions Pin
CPallini23-Nov-10 9:24
mveCPallini23-Nov-10 9:24 
GeneralRe: Sort Functions Pin
Babylon Lion23-Nov-10 9:44
Babylon Lion23-Nov-10 9:44 
GeneralRe: Sort Functions Pin
CPallini23-Nov-10 10:06
mveCPallini23-Nov-10 10:06 
GeneralRe: Sort Functions Pin
S Houghtelin24-Nov-10 4:07
professionalS Houghtelin24-Nov-10 4:07 
AnswerUse QuickSort Pin
DarthDana24-Nov-10 4:20
professionalDarthDana24-Nov-10 4:20 
QuickSort is infinitely faster than a bubble sort. I use it exclusively. It recursively breaks the list up into smaller and smaller pieces. The resulting time-to-sort relative to the length of the list is linear instead of exponential.

Found this from Googling QUICKSORT.
There are many other sources of info out there.

void swap(int *x,int *y) 
{ 
  int temp; 
  temp = *x; 
  *x = *y; 
  *y = temp; 
}

int choose_pivot(int i,int j ) 
{ 
  return((i+j) /2); 
} 

void quicksort(int list[],int m,int n) 
{ 
  int key,i,j,k; 
  if( m < n) 
  { 
    k = choose_pivot(m,n); 
    swap(&list[m],&list[k]); 
    key = list[m]; 
    i = m+1; 
    j = n; 
    while(i <= j) 
    { 
      while((i <= n) && (list[i] <= key)) 
      i++; 
      while((j >= m) && (list[j] > key)) 
      j--; 
      if( i < j) 
        swap(&list[i],&list[j]); 
    } 
// swap two elements 
    swap(&list[m],&list[j]); 
// recursively sort the lesser list 
    quicksort(list,m,j-1); 
    quicksort(list,j+1,n); 
    } 
} 

GeneralRe: Use QuickSort Pin
Maximilien24-Nov-10 5:42
Maximilien24-Nov-10 5:42 
GeneralRe: Use QuickSort Pin
Matthew Barnett24-Nov-10 5:46
Matthew Barnett24-Nov-10 5:46 
GeneralRe: Use QuickSort Pin
«_Superman_»24-Nov-10 7:30
professional«_Superman_»24-Nov-10 7:30 
GeneralRe: Use QuickSort Pin
ThatsAlok11-Jul-11 21:18
ThatsAlok11-Jul-11 21:18 
AnswerRe: Sort Functions Pin
James Lonero24-Nov-10 9:00
James Lonero24-Nov-10 9:00 
AnswerRe: Sort Functions Pin
dpminusa24-Nov-10 13:32
dpminusa24-Nov-10 13:32 
AnswerRe: Sort Functions Pin
James Curran28-Nov-10 5:18
James Curran28-Nov-10 5:18 
QuestionCButton question Pin
DerrekCurtis23-Nov-10 7:09
DerrekCurtis23-Nov-10 7:09 
AnswerRe: CButton question Pin
«_Superman_»23-Nov-10 7:19
professional«_Superman_»23-Nov-10 7:19 
AnswerRe: CButton question Pin
Member 399486624-Nov-10 3:13
Member 399486624-Nov-10 3:13 
QuestionDebugging multiple processes within a visual studio solution Pin
aevanscambs23-Nov-10 6:00
aevanscambs23-Nov-10 6:00 
AnswerRe: Debugging multiple processes within a visual studio solution Pin
Eugen Podsypalnikov23-Nov-10 6:02
Eugen Podsypalnikov23-Nov-10 6:02 
AnswerRe: Debugging multiple processes within a visual studio solution Pin
«_Superman_»23-Nov-10 7:16
professional«_Superman_»23-Nov-10 7:16 
QuestionListing DLL Exports Pin
softwaremonkey23-Nov-10 5:23
softwaremonkey23-Nov-10 5:23 
AnswerRe: Listing DLL Exports PinPopular
Eugen Podsypalnikov23-Nov-10 5:54
Eugen Podsypalnikov23-Nov-10 5:54 
GeneralRe: Listing DLL Exports Pin
softwaremonkey23-Nov-10 6:09
softwaremonkey23-Nov-10 6:09 
AnswerRe: Listing DLL Exports Pin
«_Superman_»23-Nov-10 7:21
professional«_Superman_»23-Nov-10 7:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.