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

Printable View

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

- 07-08-2009tabstop
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. - 07-08-2009sean
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?

- 07-08-2009clairmonte
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 - 07-08-2009ಠ_ಠ
- 07-09-2009clairmonteno help
hi guys i complete that assigment, is willing to share since no one could have help

- 07-10-2009nonoob
I don't know what that means. Is

**clairmonte**angry that we didn't do the homework? - 07-10-2009ಠ_ಠ
I think so, I provided a lot of help

- 07-10-2009Adak
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);

}

- 07-10-2009iMalc