Presentation is loading. Please wait.

Presentation is loading. Please wait.

Sorting Develop a sorting algorithm

Similar presentations


Presentation on theme: "Sorting Develop a sorting algorithm"— Presentation transcript:

1 Sorting Develop a sorting algorithm
Computer Science Sorting Develop a sorting algorithm

2 Learning Objectives Be able to complete the Tally Array program.
Be able to develop a strategy to put information in order using an array.

3 Sorting How do you put things in order? (Low to high) Pseudo-Code
Develop a sorting algorithm

4 Bubble Sort Low High 8 2 6 9 21 1 Speed: O(n2) Stability: Stable
How it works: Check- Switch Show it after each pass Low High

5 Bubble Sort {This is just the code for Bubble Sort}
for pass:= 1 to (size -1) do begin for check:= 1 to size-1 do if TheArray[check]>TheArray[check+1] then dummy:= TheArray[check]; TheArray[check]:= TheArray[check+1]; TheArray[check+1]:= dummy; End; {Of the if and the for check loop} end;{Of the for pass loop}

6 Sorting Program Option #1 Option #2
Randomly generate 100 scores from 1 to 50. Show the numbers before they are sorted show the numbers after they are sorted. Push: Show graphically the numbers being sorted. Push: Change it to 5000 numbers and time how long it takes for them to sort. Push: Improve the efficiency of the sort. Option #2 Input 10 race times for the 100 meter dash. (enter the time as seconds) Output: The times sorted from fastest to slowest. Push: Enter the name that goes with each time, and show a chart of names and times for the race.


Download ppt "Sorting Develop a sorting algorithm"

Similar presentations


Ads by Google