Thread: sort algorithm

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    5

    Red face sort algorithm

    how do i go about conducting a sort algorithm experiment using bubble sort, quicksort, and one other. Please help

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You split the algorithms into groups, give one of them caffeine pills and the other a placebo and stand back.






    REAL ANSWER: Presumably you want to run each of them and see which one finishes first.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    That's a pretty vague question. What kind of experiment do you want to do? Do you know what each algorithm is? Have you implemented them individually?

  4. #4
    Registered User
    Join Date
    Jul 2009
    Posts
    5
    ok guys i have to do an assignment, the lecture say that it is ok to get the sorting algorithm online. i was really hoping that you could have point me in the right direction. any how here is the assignment:
    Select three sorting algorithm
    -bubble sort
    -quicksort
    -and another of my choice
    Conduct empirical experiment to compare and contrats their run time performance. Discuss issues that impact run time performance. Use graph to illustrate results.
    So here it is, any ideas and/or sort algorithms that i can use or modify to get what i want

  5. #5
    Banned ಠ_ಠ's Avatar
    Join Date
    Mar 2009
    Posts
    687
    Quote Originally Posted by clairmonte View Post
    ok guys i have to do an assignment, the lecture say that it is ok to get the sorting algorithm online. i was really hoping that you could have point me in the right direction. any how here is the assignment:
    Select three sorting algorithm
    -bubble sort
    -quicksort
    -and another of my choice
    Conduct empirical experiment to compare and contrats their run time performance. Discuss issues that impact run time performance. Use graph to illustrate results.
    So here it is, any ideas and/or sort algorithms that i can use or modify to get what i want
    Sorting algorithm - Wikipedia, the free encyclopedia

    have fun
    ╔╗╔══╦╗
    ║║║╔╗║║
    ║╚╣╚╝║╚╗
    ╚═╩══╩═╝

  6. #6
    Registered User
    Join Date
    Jul 2009
    Posts
    5

    no help

    hi guys i complete that assigment, is willing to share since no one could have help

  7. #7
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    I don't know what that means. Is clairmonte angry that we didn't do the homework?

  8. #8
    Banned ಠ_ಠ's Avatar
    Join Date
    Mar 2009
    Posts
    687
    I think so, I provided a lot of help
    ╔╗╔══╦╗
    ║║║╔╗║║
    ║╚╣╚╝║╚╗
    ╚═╩══╩═╝

  9. #9
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Here's a good start:

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    
    #define Max 28000
    
    int A[Max];
    
    void showIt(void);
    int sort_function(const void *a, const void *b);
    
    int main(void)  {
       int i, j, gap, swaps, temp, value;
       clock_t start, stop;
       
       //Insertion sort
       for(i = 0; i < Max; i++)
          A[i] = rand() % 1000;
       start = clock();
       for(i = 1; i < Max; i++)  {
          value = A[i];
          j = i - 1;
          while(j >= 0 && A[j] > value)  {
             A[j + 1] = A[j];
             --j;
          }
          A[j+1] = value;
       }
       stop = clock();
       printf("\n Insertion?? sort, used %f seconds", (stop-start)/CLK_TCK);
    //   i = getchar();
    
    //   showIt();
    
    //C Standard Library median of 3, Quicksort
       for(i = 0; i < Max; i++)
          A[i] = rand() % 1000;
       start = clock();
       qsort(A, Max, sizeof(A[0]), sort_function);
      
       stop = clock();
       printf("\n Qsort used %f seconds", (stop-start)/CLK_TCK);
       //i = getchar();
    
    //   showIt();
    
    void showIt(void) {
       int i;
       for(i = 0; i < Max; i++)
          printf("%4d ", A[i]);
    
    }
    int sort_function(const void *a, const void *b)
    {
         return(*(int*)a - *(int*)b);
    }

  10. #10
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by nonoob View Post
    I don't know what that means. Is clairmonte angry that we didn't do the homework?
    Maybe.
    clairmonte didn't even state what part he/she was having trouble with, so how were we to know what would have even been useful.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. JavaScript like sort algorithm?
    By audinue in forum C Programming
    Replies: 2
    Last Post: 07-28-2008, 12:27 AM
  2. choosing right sort algorithm
    By Micko in forum C++ Programming
    Replies: 15
    Last Post: 05-29-2006, 10:38 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Replies: 2
    Last Post: 05-06-2003, 08:34 AM
  5. Sort algorithm and an ugly error
    By Trauts in forum C++ Programming
    Replies: 7
    Last Post: 02-25-2003, 12:36 PM