# Chap05 - Chapter 5 Algorithms Click to edit Master subtitle...

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

Click to edit Master subtitle style Chapter 5 – Algorithms CECS 230 Spring 2010 (c) Tim Hardin 2010

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

View Full Document
Algorithm Definition: An ordered set of unambiguous, executable steps that defines a terminating process.
Algorithms? List all positive integers List all factors of positive integer Determine the greatest common divisor of two positive integers

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

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

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

View Full Document
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)
Algorithm control types Iterative Have looping control structures Recursive Call themselves

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

View Full Document
Mystery Algorithm int mystery( a, b ) // a > b { if ( b == 0 ) return a; else return ( mystery( b, a mod b ) ); }
Easier to code? Easier to understand?

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 26

Chap05 - Chapter 5 Algorithms Click to edit Master subtitle...

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

View Full Document
Ask a homework question - tutors are online