- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between Insertion Sort and Selection Sort
In Insertion Sort, the values are inserted in a list/array wherein some of the values are previous sorted.
It is a stable sorting algorithm.
The best case time complexity is O(N) (when the list has been sorted in ascending order).
A key value is defined, and the array is iterated from the beginning to the end.
The current element during iteration is compared to the key value.
The number of comparison operations made during insertion sort is less than the number of the element swapping that is done.
If the key element is smaller than the element with which it is being compared, the previous elements are compared with it.
The elements greater than key are moved one position up to make space for the element that is swapped.
The elements are known before hand, only their position is determined during insertion sort.
In Selectin Sort, at first, the minimum or the maximum number from the list is obtained.
The list is sorted in ascending or descending order.
It is considered as an unstable sorting algorithm.
The time complexity in all cases is O(n squared).
It is less efficient in comparison to insertion sort.
The number of comparisons made during iterations is more than the element swapping that is done.
The location of every element in the list is previously known.
This means the user only searches for the element that needs to be inserted at the specific position.
- Difference Between Bubble Sort and Selection Sort
- Insertion Sort
- Selection Sort
- Difference Between Quick Sort and Merge Sort
- Insertion Sort in C#
- Insertion sort in Java.
- Insertion Sort List C++
- Selection sort in Java.
- Binary Insertion Sort in C++
- Python Program for Insertion Sort
- Insertion Sort in Python Program
- Insertion sort using C++ STL
- Insertion Sort List in C++
- C++ Program Recursive Insertion Sort
- Selection Sort program in C#