Ask your own question, for FREE!
Computer Science 11 Online
OpenStudy (anonymous):

i need an algorithm to compare heapsort vs quicksort

OpenStudy (anonymous):

Implement heapsort and quicksort yourself, and then time them or count the number of comparisons.

OpenStudy (anonymous):

Try something like this: public static void main(String[] args) { int []a1={11,8,6,4,2,16,9,10,14,8,7}; int []a2={11,8,6,4,2,16,9,10,14,8,7}; long estimatedTime = System.nanoTime(); long startTime = System.nanoTime(); sortHeap(a1); //you will need to write this class estimatedTime = System.nanoTime()-startTime; System.out.print("Heap sort took :"+estimatedTime.toString); startTime = System.nanoTime(); sortQuick(a2); //you will need to write this class estimatedTime = System.nanoTime()-startTime; System.out.print("Quick sort took :"+estimatedTime.toString); //compare for(int i=0;i<a1.length;i++){ System.out.print(a1[i] + " "+ a2[i]); } } }

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!