CS2800-Algorithms-Growth-Rates_v.4

CS2800-Algorithms-Growth-Rates_v.4 - Discrete Math CS 2800...

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

View Full Document Right Arrow Icon
1 Discrete Math CS 2800 Prof. Bart Selman selman@cs.cornell.edu Module Algorithms and Growth Rates
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 The algorithm problem Specification of all legal inputs and Specification of desired output as a function of the input Any legal input The algorithm The desired output
Background image of page 2
Examples of algorithmic problems Problem 1 : Input: A list L, of integers Output: The sum of the integers on L Problem 3 : Input: A road map of cities with distances attached to the road map, and two designated cities A and B Output: A description of the shortest path between A and B Problem 2 : Input: Two texts A and B in English Output: The list of common words in both texts
Background image of page 3

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

View Full DocumentRight Arrow Icon
Instance of an algorithmic problem Size of an instance An instance of an algorithmic problem is a concrete case of such a problem with specific input . The size of an instance is given by the size of its input . Examples of instances: An instance of problem 1 : L= 2, 5, 26, 8, 170, 79, 1002 Problem 1 : Input: A list L, of integers Output: The sum of the integers on L Size of instance length of list Size of instance = |L| = 7 We use a “natural” measure of input size. Why generally ok? Strictly speaking we should count bits.
Background image of page 4
Examples of instances Problem 3 : Input: A road map of cities with distances attached to the road map, and two designated cities A and B Output: A description of the shortest path between A and B 1 2 3 4 5 6 2 4 2 1 3 4 2 3 2 Size of instance Number of cities and roads A particular instance : Size of instance: 6 nodes 9 edges The size of an instance is given by the size of its input .
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Algorithm Definition: An algorithm is a finite set of precise instructions for performing a computation or for solving a problem. In general we describe algorithms using pseudocode : i.e., a language that is an intermediate step between an English language description of an algorithm and an implementation of this algorithm in a programming language
Background image of page 6
7 Properties of an Algorithm Input: an algorithm has input values from a specified set. Output: for each set of input values an algorithm produces output values from a specified set. The output values are the solution of the problem. Definiteness: The steps of an algorithm must be defined precisely. Correctness: An algorithm should produce the correct output values fro each set of input values. Finiteness: an algorithm should produce the desired output after a finite (but perhaps large) number of steps for any input in the set. Effectiveness: It must be possible to perform each step of an algorithm exactly and in a finite amount of time. Generality: the procedure should be applicable for all the problems of the desired from, not just for a particular set of input values. Distinction between: “problem” and “problem instance” Quite confusing for folks outside CS. Alg. should work for all instances!
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 Algorithm: Finding the Maximum Element in a Finite Sequence procedure max ( a 1 ,a 2 ,…, a n : integers) max := a 1 for i := 2 to n if max < a i then max := a i { max is the largest element}
Background image of page 8
Computer Programming Programmer (human) Compiler (software) Algorithm
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 10/25/2009 for the course CS 2800 at Cornell University (Engineering School).

Page1 / 60

CS2800-Algorithms-Growth-Rates_v.4 - Discrete Math CS 2800...

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