bubble sort insertion sort selection sort merge sort heap sort quick sort

O(n2) O(n2) O(n2) O(nlogn) O(nlogn) O(n2)

a: array of integers; num:=100; n:=50; max:=1 million; while (i<=max) do bublesorttotaltime := 0; bubblemax := 0; : for j:=1 to num loop a:=random array of integers of length i; starttime := system.time(); bubblesort(a); endtime := system.time(); totaltime := endtime-starttime; bubblesorttotaltime += totaltime; if totaltime > bubblemax then bubblemax := totaltime; insertionsort(a); : quicksort(a); end loop; avgbubblesorttime := bubblesorttotaltime/num; i:=i*2; end loop;

Sign up to vote on this title
UsefulNot useful