Courses & Projects

9. Insertion Sort and Merge Sort in C++

insertion sort and merge sort in c++

Insertion Sort and Merge Sort in C++

Insertion Sort

The insertion sort algorithm puts a set of elements in a specific order. Every iteration of the insertion sort algorithm moves an element from the unsorted to the sorted portion of the list until all of the elements in the list are sorted.

Working of Insertion Sort

  • The first step is to compare the element with its neighboring element.
  • And if each comparison shows that the element can be inserted at a specific place, then space is made for it by relocating the other elements in one position to the right and inserting the element at the appropriate place.
  • The above process is continued until all of the elements in the array are in their proper location.

Merge Sort

Merge Sort is a popular sorting algorithm that is based on the Divide and Conquers Algorithm idea. A problem is broken into several sub-problems in this case. Each sub-problem is addressed separately. Sub-problems are then integrated to generate the final solution.

All the details discuss with code in the video below:

 

[su_youtube url=”https://www.youtube.com/watch?v=LANnMizmH4E&list=PLvefQOIyFZO8OZ4_1loaDGx94T43v9NBf&index=9″] [su_button id = “download” url=”https://drive.google.com/drive/folders/1BcTDxx4XVuaeDr18Vsmxg8QpCJHm__aN?usp=sharing” target=”blank” center=”yes” radius=”10″ icon=”icon: arrow-down” desc=”Sorting”]Download Now[/su_button]

Recommended:

Leave a Comment