← BYTES
Algorithms·Starter·Ref: 12.1.14

What is insertion sort's basic approach to sorting an array?

Have a question about this video? Mention reference 12.1.14 when you contact us.

a.It sorts by repeatedly removing the maximum element
b.It always splits the array in half recursively
c.It only works on arrays of even length
d.It builds the sorted output one element at a time, inserting each new element into its correct position among the already-sorted elements to its left
Insertion sort processes elements left to right, taking each new element and shifting it leftward past any larger already-sorted elements until it reaches its correct position -- much like sorting a hand of playing cards one at a time; it's efficient (close to O(n)) on nearly-sorted input but O(n^2) worst case on reverse-sorted input.

Find this on YouTube & Instagram

Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:

#BYTES#BYTES12114#Algorithms