0% found this document useful (0 votes)
2 views3 pages

Insertion Sort Algorithm Explained

Uploaded by

kushalkansal0
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Insertion Sort Algorithm Explained

Uploaded by

kushalkansal0
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Insertion Sort Algorithm



Insertion sort
We start with the second element of the array as the first element is
assumed to be sorted.
 Compare the second element with the first element if the second
element is smaller then swap them.
 Move to the third element, compare it with the first two elements, and
put it in its correct position
 Repeat until the entire array is sorted
Time complexity: O(N ), (where N = size of the array), for the worst, and
2

average cases.
Space Complexity: O(1)

You might also like