{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CS2800-Algorithms-Growth-Rates_v.4

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

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

1 Discrete Math CS 2800 Prof. Bart Selman [email protected] Module Algorithms and Growth Rates

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

View Full Document
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
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

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

View Full Document
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.
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 .

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

View Full Document
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
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!

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

View Full Document
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}
Computer Programming Programmer (human) Compiler (software) Algorithm

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 ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern