As the selection sort has three main characteristic, the first that
it is In-place algorithm and second it is a stable algorithm, and
third it is simple while all other algorithm of order O (n2
not have all these characteristics. So it is felt that why its time
complexity should not improve. In this scenario, the author
capture the idea from old selection sort that if we sort two data
elements (smallest as well as largest) of the given data in
single iteration, then its time can be reduced.
Therefore our OSSA sorts the data from front and rear ends of
the array and finishes the execution of outer loop when it
reaches at the middle of the array. In its first iteration it finds
the smallest and largest data elements of array and place those
in their desired locations, then it finds the next smallest and
largest data elements from the remaining array and sorts those
in their next respective locations in the array. In this way it
executes half the iteration of the outer loop, while old SS only
finds either smallest or largest (but not both ) element of array
and requires the full iteration of outer loop.
Although OSSA is still O(n2
level has very much improved as compared to other sorting
algorithm of said order i.e Bubble sort, insertion sort etc.
), but In this way its performance