Search Header Logo
Sorting Algorithms

Sorting Algorithms

Assessment

Presentation

Computers

9th - 12th Grade

Practice Problem

Easy

Created by

Katherine Valenti

Used 1+ times

FREE Resource

80 Slides • 6 Questions

1

Sorting Algorithms

2

Students will be able to...

  • Describe the step-by-step process of selection and insertion sort algorithms

  • Implement and modify sorting algorithms in Java

  • Predict and trace the sorting process on sample datasets

  • Compare the efficiency of algorithms using simulations and visualizations

  • Reflect on how dataset size and order affect algorithm performance

3

Warm Up

4

Open Ended

If you had to organize books by height or name, how might you do it?

5

Warm Up

  • Compare items and switch them around

  • Use rules to decide which order is better

6

Open Ended

What are some ways computers could organize a list of numbers or names?

7

Warm Up

  • Go one by one and put each in the right spot

  • Find the shortest and move it to the start

8

Open Ended

Why might one method of sorting be better than another in some cases?

9

Warm Up

  • If the list is already mostly sorted

  • Some methods are faster with short lists

10

media

11

media

12

media

13

media

14

media

15

media

16

media

17

media

18

media

19

media

20

media

21

media

22

media

23

media

24

media

25

media

26

media

27

media

28

media

29

media

30

media

31

media

32

media

33

media

34

media

35

media

36

media

37

media

38

media

39

media

40

media

41

media

42

media

43

media

44

media

45

media
media

46

media

47

media

48

media

49

media

50

media

51

media

52

media

53

media

54

media

55

media

56

media

57

media

58

media

59

media

60

media

61

media

62

media

63

media

64

media

65

media

66

media

67

media

68

media

69

media

70

media

71

media

72

media

73

media

74

media

75

media

76

media

77

Insertion Sort vs. Selection Sort

  • While loop will only run if the value directly before the unsorted value is less than the unsorted value

  • The while loop won't execute for most of the unsorted values, lowering the execution count

media

78

Insertion Sort vs. Selection Sort

  • Insertion Sort has to shift every single value when executing the while loop, as every value is less than the one before it

  • Selection Sort will only swap 2 values- 4 and 0 then 3 and 1 before being completely sorted

media

79

media

80

Now It's Your Turn

  • Head to CodeHS and access the Sorting Algorithms (Day 2) modules. You will be completing:

    • Insertion Sort Simulation

    • Exploration: Insertion Sort

    • Visualizing Sorting Algorithms, Pt 1

    • Visualizing Sorting Algorithms, Pt 2

    • Sorting Algorithm Reflection

81

Wrap Up

82

Match

Match the following concepts:

Sorting algorithm that takes an array of values and sorts it. The idea is to have a sorted part of the list and an unsorted part. On each iteration, finds the lowest value in the unsorted section of the list and adds it to the end of the sorted part.

Sorting algorithm that sorts an array of values. The idea is to have a sorted part of the list and an unsorted part. On each iteration of the algorithm, we grab the next unsorted element and place it in its proper position in the sorted section.

The ability to achieve an end goal with little to no waste.

A condition that holds true throughout a loop’s execution (e.g., part of the array is always sorted)

A method for reordering data into a specific sequence

Selection Sort

Insertion Sort

Efficiency

Loop Invariant

Sorting Algorithm

83

Open Ended

What’s one difference between selection and insertion sort in how they treat the array?

84

Wrap Up

  • Selection Sort- finds the smallest and swaps

  • Insertion Sort- moves elements to insert each item in the correct position

85

Open Ended

What did you notice when sorting large datasets in the simulations?

86

Wrap Up

  • Insertion Sort seemed faster when the data was almost sorted

  • Both were slow on big random lists

Sorting Algorithms

Show answer

Auto Play

Slide 1 / 86

SLIDE