English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

how can write program that can find running time of bubble sort, insertion sort, heap sort, merge sort and quick sort?

2007-12-16 17:32:12 · 4 answers · asked by Abdulaziz 1 in Computers & Internet Programming & Design

In C++ plz

2007-12-16 17:35:00 · update #1

LOL.. it is not homework but it help me to find running time to any sort.
I understand running time but I have no idea how to write the code?

2007-12-16 20:22:16 · update #2

4 answers

Why not just run each 5000 times, and note the before and after times?

2007-12-16 18:10:29 · answer #1 · answered by Kasey C 7 · 0 1

This sounds dreadfully like a programming homework problem.
Maybe this will put you on the right path, instead of doing your work for you:

Note that the efficiency of an operation can be had by deriving it's Big-O value. You can, of course, derive this from the algorithm by evaluation (or solving its recurrence relation). However, if you're going to solve this by writing a program to do it, it's a little bit more complex. Either you set up a base "n" and calculate given cycles through, or you watch a thread being processed and determine the difference in time till completion.

2007-12-17 01:38:14 · answer #2 · answered by andrew_manoske 2 · 0 1

lol!! i would like to answer your question but i dont want to do the exact code for you!
but its easier to code than to explain it in words, you probably wont understand it that way anyway!!!

use nested loops! ex..
for x < 10 x++
{ for y< 10 y++
{ if () }
c = a
a = b
b = c
}

2007-12-17 01:57:09 · answer #3 · answered by ghelo 2 · 0 1

main() {
time()
for(i=0;i<10000;i++)
quicksort();
}
time()
.
.
.
}
If you need further help you may contact me at programmer@live.in

2007-12-17 06:55:07 · answer #4 · answered by Anonymous · 0 0

fedest.com, questions and answers