other elements marked in a circle and sorted temporarily. Sorted elements inside the square 'y' are
shown.
Time Complexity
The performance of sorting algorithm depends upon the number of iterations and time to compare
them. The first element is compared with the remaining n-1 elements in pass 1. Then n-2 elements
are taken in pass 2. this process is repeated until the last element is encountered. The mathematical
expression for these iterations will be equal to
(n-l)+(n-2)+...+(n- (n-1)). Thus the expression
become n*(n-1)/2.
Thus, the number of comparisons is proportional to (n2). The time complexity of selectio ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.