This is a very simple question but I'm struggling too much to understand the concept completely.
I'm trying to understand the difference between the following statements:
- There exists an algorithm which sorts an array of n numbers in O(n) in the best case.
- Every algorithm sorts an array of n numbers in O(n) in the best case.
- There exists an algorithm which sorts an array of n numbers in Omega(n) in the best case.
- Every algorithm sorts an array of n numbers in Omega(n) in the best case.
I will first explain what is driving me crazy. I'm not sure regarding 1 and 3 - but I know that for one of them the answer is correct just by specifying one case and for the other one the answer is correct by examining all the possible inputs. Therefore I know one of them must be true just by specifying that the array is already sorted but I can't tell which. My teacher always told me to think about it like we are examining who's the heighest guy in the class and again by one of these options(1,3) it's enough to say that he is and there is no reason to examine all the class.
I do know that if we were to examine the worst case then none of these statements could be true because the best sorting algorithm without any assumptions or additional memory is Omega(nlogn).
IMPORTANT NOTE: I'm not looking for a solution (an algorithm which is able to do the matching sort) - only trying to understand the concept a little better.
Thank you!