1 / 30

TIME COMPLEXITY

TIME COMPLEXITY. Pages 247 - 256. Introduction. Even when a problem: is decidable and computationally solvable it may not be solvable in practice if the solution requires an inordinate amount of time or memory. Objectives. investigation of the: time , memory , or

orrin
Download Presentation

TIME COMPLEXITY

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. TIME COMPLEXITY

  2. Pages 247 - 256

  3. Introduction • Even when a problem: • is decidable and • computationally solvable • it may not be solvable in practice if the solution requires an inordinate amount of time or memory.

  4. Objectives • investigation of the: • time, • memory, or • Other resources required for solving computational problems. • to present the basics of time complexity theory.

  5. Objectives (cont.) • First - introduce a way of measuring the time used to solve a problem. • Then - show how to classify problems according to the amount of time required. • After - discuss the possibility that certain decidable problems require enormous amounts of time and how to determine when you are faced with such a problem.

  6. MEASURING COMPLEXITY The language

  7. MEASURING COMPLEXITY (cont.) • How much time does a single-tape Turing machine need to decide A?

  8. MEASURING COMPLEXITY (cont.) • The number of steps that an algorithm uses on a particular input may depend on several parameters: (if the input is a graph) • the number of steps may depend on : • the number of nodes, • the number of edges, and • the maximum degree of the graph, or • some combination of these and/or other factors.

  9. Analysis • worst-case analysis - consider the longest running time of all inputs of a particular length. • average-case analysis - consider the average of all the running times of inputs of a particular length.

  10. BIG-O AND SMALL-O NOTATION • Exact running time of an algorithm often is a complex expression. (estimation) • Asymptotic analysis - seek to understand the running time of the algorithm when it is run on large inputs. The asymptotic notation or big-O notation for describing this relationship is

  11. Self study • EXAMPLE 7.3 • EXAMPLE 7.4

  12. BIG-O AND SMALL-O NOTATION (cont.) • Performing this scan uses n steps. • Typically use n to represent the length of the input. • Repositioning the head at the left-hand end of the tape uses another n steps. • The total used in this stage is 2n steps. In stage 1

  13. BIG-O AND SMALL-O NOTATION (cont.) In stage 4 the machine makes a single scan to decide whether to accept or reject. The time taken in this stage is at most O(n).

  14. BIG-O AND SMALL-O NOTATION (cont.) • Thus the total time of M1 on an input of length n is O(n) + O(n2) + O(n) or O(n2 ). In other words, it's running time is O(n2), which completes the time analysis of this machine.

  15. Is there a machine that decides A asymptotically more quickly?

  16. Executed Time • Stages 1 and 5 are executed once, taking a total of O(n) time. • Stage 4 crosses off at least half the 0sand 1s is each time it is executed, so at most 1+log2n. • the total time of stages 2, 3, and 4 is (1 + log2n)O(n), or O(n log n). • The running time of M2 is O(n) + O(n logn) = O(n log n).

  17. COMPLEXITY RELATIONSHIPS AMONG MODELS • We consider three models: • the single-tape Turing machine; • the multi-tape Turing machine; and • the nondeterministic Turing machine

  18. COMPLEXITY RELATIONSHIPS AMONG MODELS (cont.) • convert any multi-tape TM into a single-tape TM that simulates it. • Analyze that simulation to determine how much additional time it requires. • simulating each step of the multi-tape machine uses at most O(t(n)) steps on the single-tape machine. • the total time used is O(t2(n)) steps. O(n) + O(t2 (n)) running time O(t2 (n))

  19. SPACE COMPLEXITY I N T R A C T A B I L I T Y

  20. Pages 303 – 308

  21. Objective • Consider the complexity of computational problems in terms of the amount of space, or memory, that they require. • Time and space are two of the most important considerations when we seek practical solutions to many computational problems. • Space complexity shares many of the features of time complexity and serves as a further way of classifying problems according to their computational difficulty.

  22. Introduction • select a model for measuring the space used by an algorithm. • Turing machines are mathematically simple and close enough to real computers to give meaningful results.

  23. Estimation the space complexity • We typically estimate the space complexity of Turing machines by using asymptotic notation. • EXAMPLE 8.3

  24. EXAMPLE 8.4

  25. SAVITCH'S THEOREM read only

  26. Pages 335 - 338 I N T R A C T A B I L I T Y

  27. Certain computational problems are solvable in principle, but the solutions require so much time or space that they can't be used in practice. Such problems are called intractable. • Turing machines should be able to decide more languages in time n3 than they can in time n2. The hierarchy theorems prove that .

More Related