Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

32
Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park

Transcript of Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Page 1: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Chapter 5Algorithms (1)

Introduction to CS

1st Semester, 2015 Sanghyun Park

Page 2: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Outline Informal Definition of an Algorithm FindLargest Three Basic Constructs Sorting Algorithms Searching Algorithms Recursion Algorithm Performance (next file) Time Complexity (next file) Asymptotic Notation (next file) Growth Rate (next file)

Page 3: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Informal Definition of AlgorithmUsed in Computer

Page 4: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Finding the Largest NumberAmong Five Integers

Page 5: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Defining Actions inFindLargest Algorithm

Page 6: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

FindLargest Refined

Page 7: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Generalization of FindLargest

Page 8: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Three Basic Constructs

Page 9: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Flowcharts for Three Constructs

Page 10: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Pseudocode for Three Constructs

Page 11: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Concept of Subalgorithm

Page 12: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Summation

Page 13: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Product

Page 14: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Selection Sort

Page 15: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Example of Selection Sort (1/2)

Page 16: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Example of Selection Sort (2/2)

Page 17: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Selection Sort Algorithm

Page 18: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Bubble Sort

Page 19: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Example of Bubble Sort (1/2)

Page 20: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Example of Bubble Sort (2/2)

Page 21: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Insertion Sort

Page 22: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Example of Insertion Sort (1/2)

Page 23: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Example of Insertion Sort (2/2)

Page 24: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Search Concept

Page 25: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Example of Sequential Search (1/2)

Page 26: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Example of Sequential Search (2/2)

Page 27: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Sequential Search AlgorithmWhen List is Sorted

Page 28: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Example of Binary Search

Page 29: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Binary Search Algorithm

Page 30: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Iterative Definition of Factorial

Page 31: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Recursive Definition of Factorial

Page 32: Chapter 5 Algorithms (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Tracing Recursive Solution toFactorial Problem