1 / 51

Complexity Analysis of Algorithms 1

Some background knowledge:. What is an Algorithm? Why consider Efficiency and Correctness? What is Computational Complexity? What are the factors affecting efficiency? What is the Motivation for studying Algorithms?. Algorithms and Programs. Algorithm: a method or a process followed to solve a p

yoko
Download Presentation

Complexity Analysis of Algorithms 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. Complexity Analysis of Algorithms (1)

    2. Some background knowledge: What is an Algorithm? Why consider Efficiency and Correctness? What is Computational Complexity? What are the factors affecting efficiency? What is the Motivation for studying Algorithms?

    3. Algorithms and Programs Algorithm: a method or a process followed to solve a problem. A recipe. An algorithm takes the input to a problem (function) and transforms it to the output. A mapping of input to output. A problem can have many algorithms.

    4. Algorithm Properties An algorithm possesses the following properties: It must be correct. It must be composed of a series of concrete steps. There can be no ambiguity as to which step will be performed next. It must be composed of a finite number of steps. It must terminate. A computer program is an instance, or concrete representation, for an algorithm in some programming language. “Correct” means computes the proper function. “Concrete steps” are executable by the machine in question. We frequently interchange use of “algorithm” and “program” though they are actually different concepts. “Correct” means computes the proper function. “Concrete steps” are executable by the machine in question. We frequently interchange use of “algorithm” and “program” though they are actually different concepts.

    5. Mathematical Background Set concepts and notation. Recursion Induction Proofs Logarithms Summations Recurrence Relations Look over the textbook, read as needed depending on your familiarity with this material. A set has no duplicates, a sequence may have duplicates. Logarithms: We almost always use log to base 2. That is our default base.Look over the textbook, read as needed depending on your familiarity with this material. A set has no duplicates, a sequence may have duplicates. Logarithms: We almost always use log to base 2. That is our default base.

    6. Estimation Techniques Known as “back of the envelope” or “back of the napkin” calculation Determine the major parameters that effect the problem. Derive an equation that relates the parameters to the problem. Select values for the parameters, and apply the equation to yield and estimated solution. Look over the textbook, read as needed depending on your familiarity with this material. A set has no duplicates, a sequence may have duplicates. Logarithms: We almost always use log to base 2. That is our default base.Look over the textbook, read as needed depending on your familiarity with this material. A set has no duplicates, a sequence may have duplicates. Logarithms: We almost always use log to base 2. That is our default base.

    7. Estimation Example How many library bookcases does it take to store books totaling one million pages? Estimate: Pages/inch Feet/shelf Shelves/bookcase Pages/inch: Guess 500 Feet/shelf: Guess 4, actually 3 Shelves/bookcase: Guess 5, actually 7 Units check: pages/in x ft/shelf x shelf/bookcase ? pages/bookcase Pages/inch: Guess 500 Feet/shelf: Guess 4, actually 3 Shelves/bookcase: Guess 5, actually 7 Units check: pages/in x ft/shelf x shelf/bookcase ? pages/bookcase

    8. Algorithm Efficiency There are often many approaches (algorithms) to solve a problem. How do we choose between them? At the heart of computer program design are two (sometimes conflicting) goals: To design an algorithm that is easy to understand, code, debug. To design an algorithm that makes efficient use of the computer’s resources.

    9. Algorithm Efficiency (cont) Goal (1) ? To design an algorithm that is easy to understand, code, debug, is the concern of Software Engineering. Goal (2) ? To design an algorithm that makes efficient use of the computer’s resources, is the concern of data structures and algorithm analysis. When goal (2) is important, how do we measure an algorithm’s cost?

    10. How to Measure Efficiency? Empirical comparison (run programs) Asymptotic Algorithm Analysis Critical resources ? Factors affecting running time: For most algorithms, running time depends on “size” of the input. Running time is expressed as T(n) for some function T on input size n.

More Related