Thread: Bubble Sort, Qucik Sort

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    9

    Question Bubble Sort, Qucik Sort

    I need to write a program that time a bubble sort and quick sort (sorting 50,000 characters). I have the Bubble sort in the book I have but I don't have the quick sort. Does anyone know where I can find this online or a book I could reference.

    Thanks...

  2. #2
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807
    example for qsort()
    Code:
    /* qsort example */
    #include <stdio.h>
    #include <stdlib.h>
    
    int compare (const void * a, const void * b)
    {
      return ( *(int*)a - *(int*)b );
    }
    
    int main ()
    {
      int values[] = { 40, 10, 100, 90, 20, 25 };
      int * pItem;
      int n;
      qsort (values, 6, sizeof(int), compare);
      for (n=0; n<6; n++)
      {
        printf ("%d ",values[n]);
      }
      return 0;
    }
    http://www.cplusplus.com/ref/cstdlib/qsort.html
    Last edited by Vber; 03-15-2003 at 04:55 PM.

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    "where I can find this online" is a classic question which will always get you an answer of "have you tried searching?"

    http://cboard.cprogramming.com/search.php?s=
    www.google.com

    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 05-13-2009, 03:25 PM
  2. My bubble sort only sorts once
    By Muller in forum C Programming
    Replies: 8
    Last Post: 03-27-2009, 04:36 PM
  3. help with debug (bubble sort algorithm)
    By lbraglia in forum C Programming
    Replies: 5
    Last Post: 10-19-2007, 05:24 PM
  4. Bubble Sort... which type?
    By gflores in forum C++ Programming
    Replies: 8
    Last Post: 08-15-2004, 04:48 AM
  5. optimizing bubble sort
    By Sargnagel in forum C Programming
    Replies: 14
    Last Post: 01-23-2003, 06:27 AM