• Breaking News

    Wednesday, May 9, 2018

    8 time complexities that every programmer should know Computer Science

    8 time complexities that every programmer should know Computer Science


    8 time complexities that every programmer should know

    Posted: 08 May 2018 06:31 AM PDT

    Formal definition of time complexity using Turing machines?

    Posted: 08 May 2018 10:42 AM PDT

    Hi. So I've been reading Michael Sipser's intro to theoretical CS just for fun so I have no professional qualifications. But I've understood how basic automatas and the Turing machine work and the difference between recognisers and deciders and how computational problems can be reframed as the task of determining if a language is recognisable or decidable.

    And I also have a basic understanding of big-O notation and how given a high-level description of an algorithm we can determine the time complexity.

    But how is time complexity defined formally using Turing machines?

    A computable function is a function for which there exists a Turing machine such that when the input string is written on the tape at the start, the machine will halt leaving the output on the tape.

    Time could be measured in terms of the number of changes in state of the Turing machine it takes from start to halt. So I can imagine each computable function would have a table as follows:

    Example taken is the look-and-say value of a number.

    Input Output Steps taken (random figures)
    1 11 6
    23456 1213141516 104
    0000007 6017 91
    42 1412 164839274648
    and so on....

    So I've designed a Turing machine that satisfies the task. I've also designed it such that it takes an unusually large number of steps for processing the input 42.

    How do we determine whether the Turing machine functions in O(n) or O(n^2) or O(2^n)?

    Is n the length of the input or the output or some combination of both? It is possible that the machine took more steps simply because the input or output is unusually large. (It is possible for small inputs to have unusually large expected outputs or large inputs to expect small outputs) It is also possible that for different inputs of the same length the machine make take vastly different numbers of steps to reach the output (even if the output is small in length).

    P.S. I'm asking primarily because I want to understand the P versus NP problem.

    submitted by /u/ghosts_in_the_code
    [link] [comments]

    No comments:

    Post a Comment