In insertion sort what happens is, we assume the first element of the array as already sorted. Then we take the next element and compare it with the previous element and place it accordingly depending if it is greater or smaller...
prerequisites: Bubble Sort What if the array is already half sorted? For example:[23,44,0,1,2,3] Now as you can see in the above example the array from the element 0 is already sorted.If we use bubble sort here it will still compare all...
What is Sorting? Sorting refers to arrange the elements in the array in ascending or descending order.It compares the adjacent elements and shifts the elements accordingly Complexity: worst and average case is – O(n2) for example: [10,24,0,5,33,2]——–>[0,2,5,10,24,33] The code given below...