Insertion sort iterates, consuming one input element each repetition, and grows a sorted output list. At each iteration, insertion sort removes one element from the input data. If is is smaller than the largest value in the sorted list, it finds the correct position within the sorted list, shifts all the larger values up to make a space, and inserts into that correct position. It repeats until no input elements remain.
Comments
Leave a comment