Skip to Main Content
Programming and Data Structures
book

Programming and Data Structures

by Ashok Kamthane
August 2009
Intermediate to advanced content levelIntermediate to advanced
604 pages
21h 39m
English
Pearson India
Content preview from Programming and Data Structures
Searching and Sorting 575
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.
Start your free trial

You might also like

Learning Data Structures and Algorithms

Learning Data Structures and Algorithms

Rod Stephens
Data Structures and Algorithms in C++, Second Edition

Data Structures and Algorithms in C++, Second Edition

Michael T. Goodrich, Roberto Tamassia, David M. Mount

Publisher Resources

ISBN: 9789332506343