The best programs are written so that computing machines can perform them quickly and so that human beings can understand them clearly. A programmer is ideally an essayist who works with traditional aesthetic and literary forms as well as mathematical concepts, to communicate the way that an algorithm works and to convince a reader that the results will be correct. ― Donald E. Knuth

# Algorithms

## Sorting

Problem :-
Implement the Insertion sort algorithm.

Solution :-
This algorithm works by taking elements from an unsorted array one by one and inserting them in their proper position in the new sorted array. This invloves comparison and shifting operation.
Complexity of the algorithm is O(n2).
Consider the following array { 7, 2, 5, 3, 4 }. Let's see how Insertion sort technique works :-

First Iteration :: { 7, 2, 5, 3, 4 } -> { 2, 7, 5, 3, 4 } ( 2 is placed in its proper position and 7 is shifted )

Second Iteration :: { 2, 7, 5, 3, 4 } -> { 2, 5, 7, 3, 4 } ( 5 is placed in its proper position and 7 is shifted )

Third Iteration :: { 2, 5, 7, 3, 4 } -> { 2, 3, 5, 7, 4 } ( 3 is placed in its proper position and 5 & 7 are shifted )

Fourth Iteration :: { 2, 3, 5, 7, 4 } -> { 2, 3, 4, 5, 7 } ( 4 is placed in its proper position and 5 & 7 are shifted )