This article was automatically translated from the original Turkish version.
+2 More
Addition is a sorting algorithm that places one unsorted element at a time into its correct position in each iteration.
Step 1: The first element in the array is assumed to be sorted. The second element is selected and stored separately as the key.
The key is compared with the first element. If the first element is greater than the key, the key is placed before the first element.
Step 2: Step to together the first two elements are now sorted.
The third element is selected and compared with the elements to its left. It is placed immediately after the first element that is smaller than it. If no smaller element exists, it is placed at the beginning of the array.
Step 3: Similarly, each remaining unsorted element is placed in its correct position.
No Discussion Added Yet
Start discussion for "Insertion Sort Algorithm" article
Working Principle
Insertion Sort Algorithm with Java Code