Chap05 - Chapter 5 Algorithms Click to edit Master subtitle style CECS 230 Spring 2010(c Tim Hardin 2010 Algorithm Definition An ordered set of

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Click to edit Master subtitle style Chapter 5 – Algorithms CECS 230 Spring 2010 (c) Tim Hardin 2010
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Algorithm Definition: An ordered set of unambiguous, executable steps that defines a terminating process.
Background image of page 2
Algorithms? List all positive integers List all factors of positive integer Determine the greatest common divisor of two positive integers
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Why algorithms? Repeatable Efficient??? Implementable on any platform??? Algorithms are the basis of problem solving Fill in the blank: 110, 20, 12, 11, 10, ___
Background image of page 4
Algorithm representation Pseudocode Looks much like C or JAVA Common ‘language’ for all programmers Allows for study of algorithm
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Euclid’s Algorithm procedure gcd(a,b) // greatest common denom { while ( b != 0 ) { temp = b; b = a mod b; a = temp; } return a; } Example: gcd(1624,805)
Background image of page 6
Algorithm control types Iterative Have looping control structures Recursive Call themselves
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Mystery Algorithm int mystery( a, b ) // a > b { if ( b == 0 ) return a; else return ( mystery( b, a mod b ) ); }
Background image of page 8
Easier to code? Easier to understand?
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/04/2010 for the course CECS 230 taught by Professor Hardin during the Spring '10 term at University of Louisville.

Page1 / 26

Chap05 - Chapter 5 Algorithms Click to edit Master subtitle style CECS 230 Spring 2010(c Tim Hardin 2010 Algorithm Definition An ordered set of

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online