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

Slides:



Advertisements
Similar presentations
Algorithms.
Advertisements

Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 1- 1.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 8- 1.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 6- 1.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 2- 1.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 4- 1.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 9- 1.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 18 Indexing Structures for Files.
Chapter 14 An Overview of Query Optimization. Copyright © 2005 Pearson Addison-Wesley. All rights reserved Figure 14.1 Typical architecture for.
© 2010 Pearson Education, Inc. All rights reserved.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Chapter 2: Algorithm Discovery and Design
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Fluency with Information Technology Third Edition by Lawrence Snyder Chapter.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 11 Object, Object- Relational, and XML: Concepts, Models, Languages,
Chapter 2 The Algorithmic Foundations of Computer Science
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn.
Chapter 1 Computer Networks and the Internet. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 1-2.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand basic loop concepts: ■ pretest loops and post-test loops ■ loop.
Chapter 1 Overview of Computers and Programming. Copyright ©2004 Pearson Addison-Wesley. All rights reserved.1-2 Figure 1.3 Components of a Computer.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 Part 1 Conditionals and Loops.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 10: Recursion Problem Solving and Program Design in C 5th Edition.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Eleventh Edition by J.
Copyright © 2015 Pearson Education, Inc. Chapter 5: Algorithms.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Limits.
Chapter 5 Algorithms © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter 5 Algorithms Introduction to computer, 2nd semester, 2010/2011 Mr.Nael Aburas Faculty of Information Technology.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 11.5 Lines and Curves in Space.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 4 Applications of the Derivative.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1 Functions.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Recursive Solutions Recursion is an extremely powerful problem-solving.
Chapter 5 Algorithms. © 2005 Pearson Addison-Wesley. All rights reserved 5-2 Chapter 5: Algorithms 5.1 The Concept of an Algorithm 5.2 Algorithm Representation.
Chapter 5: 演算法 Algorithms 陳以德助理教授 : 高醫大舊二棟 轉 2586
Searching Chapter 18 © 2015 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures and Abstractions with Java, 4e Frank.
Chapter 5 Algorithms © 2007 Pearson Addison-Wesley. All rights reserved.
Computer Science: An Overview Eleventh Edition
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 5 Integration.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 5 Repetition.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Invitation to Computer Science 5 th Edition Chapter 2 The Algorithmic Foundations of Computer Science.
Computer Science: An Overview Eleventh Edition
Chapter 6 Repetition Objectives ❏ To understand basic loop concepts:
Chapter 5: Algorithms Computer Science: An Overview Tenth Edition
Computer Science — An Overview J. Glenn Brookshear
Chapter 2 Part 1 Data and Expressions.
Computer Science: An Overview Tenth Edition
Presentation transcript:

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

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

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

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

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

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-6 Iterative Algorithms EXAMPLES : Sequential search Insertion sort Selection sort

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

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-8 Figure 5.10 Insertion sort

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

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Fibonacci : Iterative Last  0; Current  1; while(Current <100) do (print the value assigned to Current; Temp  Last; Last  Current; and Current  Last+Temp;) 5-10

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-11 Recursion The execution of a procedure leads to another execution of the procedure. Multiple activations of the procedure are formed, all but one of which are waiting for other activations to complete. Base case =degenerative case EXAMPLE: Binary search

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Recursive Example 1 // initial value of Current is 0 procedure MyWrite (Current) if(Current<3) then (print the value assigned to Current; Current  Current+1; Apply MyWrite to the value Current) 5-12

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Recursive Example 2 // input values are 0 and 1 procedure MysteryWrite (Last, Current) if(Current<3) then (print the value assigned to Current; Temp  Current+Last; Apply MysteryWrite to the values Current and Temp) 5-13

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-14 Figure 5.12 Applying our strategy to search a list for the entry John (Binary Search)

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-15 Figure 5.13 A first draft of the binary search technique

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-16 Figure 5.14 The binary search algorithm in pseudocode

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-17 Figure 5.15

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-18 Figure 5.16

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 5-19 Figure 5.17