Presentation is loading. Please wait.

Presentation is loading. Please wait.

Insertion Sort Quiz on Thursday.

Similar presentations


Presentation on theme: "Insertion Sort Quiz on Thursday."— Presentation transcript:

1 Insertion Sort Quiz on Thursday

2 Learning Objectives Review the Bubble and Selection Sorts
Understand the speed, stability and how the insertion sort works Be able to write a program that uses either the Selection or the Insertion sort. Prepare for Thursday’s Quiz over arrays, sorts, and … the semantics of a while loop.

3 Review Show after each pass of the Bubble Sort Low High
Show after each pass of the Selection Sort

4 Insertion Sort Can you describe how it works? Animation

5 Insertion Sort Details
Speed Stability How it works Your turn Low High

6 Procedure insertion(var theArray:theArrayType; size:integer);
dummy:integer; pass, check:integer; Begin for pass:= 2 to size do begin dummy:= theArray[pass]; check := pass-1; while (theArray[check]>dummy) and (check>=1) do theArray[check+1] := theArray[check]; check:=check-1; end; theArray[check+1] := dummy; End;

7 Program Options Song Sort: Input an unknown number of songs (but less than 100) Show out of order Sort Show in order Push: Let the user also enter the Style of music, and be able to sort by style. Name age sort Input: An unknown number of names and ages Output: The names and corresponding ages in a chart sorted by age. Push: Let the user decide if they want to sort by age or name, then sort and show the chart. Stats are great Input:9 integers Output: The mean, median and range of the values Push: Let the user enter an unknown number of scores, but less than 100 and calculate the above Push: Find the mode!!


Download ppt "Insertion Sort Quiz on Thursday."

Similar presentations


Ads by Google