Start a team blog
NEW โœจ
Start a team blog, invite your team, and start publishing.

Why we are using insertion sort intend of bubble sort ??what is the propose of using insertion sort ??

Jupalli SarathSai's photo
Jupalli SarathSai
ยทJan 23, 2022ยท

1 min read

Example: take a array of some size a[8]={7,6,5,4,3,2,1} In order to arrange the above array in ascending order we need to sort the values by bubble sort (or) insertion sort. According to bubble sort it take almost 21 comparisions to arrange them in the given sort order also in insertion sort the comparisions are same as bubble sort 21 comparisions to arrange them in give sort order Then what is the use of insertion sort ??? Let me explain the use of insertion sort Example: an array a[8]={1,2,3,4,5,6,7} In the above case to arrange them in ascending order Bubble take almost 21 comparisions and Insertion sort take only 6 comparisions This is the reason behind the using of insertion sort.. Thanks you for reading and like the Post ๐Ÿ˜Š