as we all know that any sorting algorithm based on comparison model has lower bound of nlogn i.e Omega(nlogn). which can be proved mathematically.
but as we all know dutch flag problem can sort 3 distinct elements (used repeatedly) in O(n) time.It is also based on comparison model but can sort in O(n) time. so how can we justify lower bound of sorting based on comparison model , because dutch flag problem kinda violates that.
please help me understanding the difference.....
Thanks
In my opinion, this is not a relevant "contradiction" of the lower bound, because it is a particular case (the possible range of values is smaller than the total number of elements, in fact it is a constant, 3) which can be exploited to find an algorithm faster than O(N*logN), which is the lower bound for a general comparison-based sorting algorithm (i.e. where you have no information about the content of the sequence).
Generally in the case where N elements are in the range 0..K with K < N you can efficiently exploit a non-comparison sort like counting sort to solve the problem in O(N).