algorithm analysis basic sorting algorithmsmi.cau.ac.kr › teaching › lecture_alg ›...

Post on 06-Jul-2020

6 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Algorithm Analysis

Basic Sorting Algorithms

Chung-Ang University, Jaesung Lee

The original version of this content is a collaboration of Dartmouth Computer Science professors Thomas Cormen and Devin Balkcom, plus the Khan Academy computing curriculum team.URL: www.khanacademy.org

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Sorting

2

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Sorting

3

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Sorting

4

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Sorting Algorithms

5

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Classification of Sorting Algorithms• Computational Complexity

6

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Classification of Sorting Algorithms• Computational Complexity

• Memory Usage

7

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Classification of Sorting Algorithms• Computational Complexity

• Memory Usage

• Recursion

8

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Classification of Sorting Algorithms• Computational Complexity

• Memory Usage

• Recursion

• Stability

9

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Classification of Sorting Algorithms• Computational Complexity

• Memory Usage

• Recursion

• Stability

• Whether or not they are a comparison sort

10

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Classification of Sorting Algorithms• Computational Complexity

• Memory Usage

• Recursion

• Stability

• Whether or not they are a comparison sort

• Adaptability

11

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Common Sorting Algorithms• Bubble sort

12

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Common Sorting Algorithms• Bubble sort

• Selection sort

13

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Common Sorting Algorithms• Bubble sort

• Selection sort

• Insertion sort

14

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Common Sorting Algorithms• Bubble sort

• Selection sort

• Insertion sort

• Merge sort

15

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Common Sorting Algorithms• Bubble sort

• Selection sort

• Insertion sort

• Merge sort

• Quick sort

16

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Selection sort

17

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Selection sort

18

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Minimum element in a subarray

19

Index 0 1 2 3 4

Value 13 19 18 4 10

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Minimum element in a subarray

20

Index 0 1 2 3 4

Value 4 19 18 13 10

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Minimum element in a subarray

21

Index 0 1 2 3 4

Value 4 19 18 13 10

“subarray”

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Minimum element in a subarray

22

Index 0 1 2 3 4

Value 4 19 18 13 10

“subarray”

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Analysis of selection sort

23

Index 0 1 2 3 4

Value 4 19 18 13 10

“subarray”

“indexOfMinimum” function

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Analysis of selection sort

24

Index 0 1 2 3 4

Value 4 19 18 13 10

“subarray”

“indexOfMinimum” function

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Analysis of selection sort

25

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Analysis of selection sort

26

Index 0 1 2 3 4

Value 4 19 18 13 10

“subarray”

“indexOfMinimum” function

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Analysis of selection sort

27

Index 0 1 2 3 4

Value 4 19 18 13 10

“subarray”

“indexOfMinimum” function

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Analysis of selection sort

28

Index 0 1 2 3 4 5 6 7

Value 1 2 3 4 5 6 7 8

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Analysis of selection sort

29

Index 0 1 2 3 4 5 6 7

Value 1 2 3 4 5 6 7 8

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Analysis of selection sort

30

Index 0 1 2 3 4 5 6 7

Value 1 2 3 4 5 6 7 8

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Analysis of selection sort

31

Index 0 1 2 3 4 5 6 7

Value 1 2 3 4 5 6 7 8

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Asymptotic analysis for selection sort

32

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Analysis of selection sort

33

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Analysis of selection sort

34

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Analysis of selection sort

35

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Insertion sort

36

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Insertion sort

37

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Insertion sort

38

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Insertion sort

39

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Insertion sort

40

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Insertion sort

41

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Insertion sort

42

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Insertion sort

43

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Insertion sort

44

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Insertion sort

45

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Insertion sort

46

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Insertion sort

47

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Insertion sort

48

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Insertion sort

49

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Insertion sort

50

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Insertion sort

51

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Inserting a value into a sorted subarray

52

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Analysis of insertion sort

53

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Analysis of insertion sort

54

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Analysis of insertion sort

55

Algorithm Analysis / Chung-Ang University / Professor Jaesung Lee

Analysis of insertion sort

56

top related