How is Big Oh calculated for sorting algorithms? I have written a program to sort a deck of cards ( n = 52 ) using Selection sort, Merge sort and Insertion sort. For each sorting algorithm, I have to calculate the computation cost. How do I do it?
Now I would be honest enough to admit that it is part of my homework but I am just asking for some help. I am new to the Big Oh notation and went through a couple of websites but couldn't figure it out in terms of sorting algorithms.
Can someone atleast give me hints?
I just referred Wikipedia on Selection sort, Insertion sort & Merge sort.
Insertion Sort: Best Case: O(n), Worst Case and Average case: O(n^2)
Selection Sort: O(n^2) for all three cases
Merge Sort: O(nlog n) for all three cases
Is that true?