{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CS2800-Algorithms-Growth-Rates_v.4

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

Info icon This 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 [email protected] Module Algorithms and Growth Rates
Image of page 1

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

View Full Document Right 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
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
Image of page 3

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

View Full Document Right 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.
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 .
Image of page 5

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

View Full Document Right 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
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!
Image of page 7

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

View Full Document Right 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}
Image of page 8
Computer Programming Programmer (human) Compiler (software) Algorithm
Image of page 9

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern