Create a Notion page like we did on Friday, and consider the situation below.
Imagine you have a pile of an unknown number of cards (like poker cards), and you need to sort them (smallest to largest). Assume they are all of the same suit. How would you do it?
Things to consider (which approach would you take?)
Write down each step in clear, precise instructions, such that someone else reading it is clear on what you would do. Then show it to someone else in your group and see if they can describe it.
After this is done, move on to the Insertion Sort discussions...
Mason
Kenny
Start with resuming Insertion Sort discussions.
i = 1
) individually, then wait for everybody else in your group to finish. Compare your arrays.while
loop, but make sure to write a separate array for each for
-loop change (i.e., every time i
changes)<aside> 💡 [ 24 | 21 | 55 | 8 | 76 | 6 | 2 | 66 | 50 | 82 ] ****
</aside>
Algorithm InsertionSort(dataList)
// dataList is a zero-indexed list/array of sortable data
// n is the length of dataList
// algorithm modifies the dataList; returns the modified list
for i = 1 to n-1 do
let j = i
while j > 0 and dataList[j] < dataList[j-1] do
swap dataList[j] and dataList[j-1]
let j = j - 1
return dataList