Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn.

Similar presentations


Presentation on theme: "Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn."— Presentation transcript:

1 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn Brookshear

2 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-2 Chapter 5: Algorithms 5.1 The Concept of an Algorithm 5.2 Algorithm Representation 5.4 Iterative Structures 5.6 Algorithm Efficiency

3 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-3 Definition of Algorithm An algorithm is an ordered set of unambiguous, executable steps that defines a terminating process.

4 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-4 Algorithm Representation Requires well-defined primitives A collection of primitives constitutes a programming language.

5 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-5 Figure 5.2 Folding a bird from a square piece of paper

6 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-6 Figure 5.3 Origami primitives

7 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-7 Pseudocode Primitives Assignment name  expression Conditional selection if condition then action

8 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-8 Pseudocode Primitives (continued) Repeated execution while condition do activity Procedure procedure name (generic names)

9 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-9 Figure 5.4 The procedure Greetings in pseudocode

10 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-10 Iterative Structures Pretest loop: while (condition) do (loop body) Posttest loop: repeat (loop body) until(condition)

11 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-11 Figure 5.6 The sequential search algorithm in pseudocode

12 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-12 Figure 5.7 Components of repetitive control

13 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-13 Figure 5.8 The while loop structure

14 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-14 Figure 5.9 The repeat loop structure

15 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-15 Figure 5.10 Sorting the list Fred, Alex, Diana, Byron, and Carol alphabetically

16 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-16 Figure 5.11 The insertion sort algorithm expressed in pseudocode

17 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-17 Algorithm Efficiency Measured as number of instructions executed Big theta notation: Used to represent efficiency classes –Example: Insertion sort is in Θ(n 2 ) Best, worst, and average case analysis

18 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-18 Figure 5.18 Applying the insertion sort in a worst-case situation

19 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-19 Figure 5.19 Graph of the worst-case analysis of the insertion sort algorithm

20 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-20 Figure 5.20 Graph of the worst-case analysis of the binary search algorithm


Download ppt "Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn."

Similar presentations


Ads by Google