Complexity Analysis
Last updated
Was this helpful?
Last updated
Was this helpful?
A very common reason for teaching Turing machines is to give an introduction to complexity analysis. Varphi provides a mechanism for determining both the time and space complexity of a Turing machine.
To analyze the complexity of a Turing machine, pass the -c
, or --complexity
, option to the Varphi Interpreter. For example, below we show a session where the complexity of a is computed on various input tapes:
Notice that if the -c
or --complexity
option is specified, prompts asking for the input tape will automatically appear.
If you do the math, you will see that the time-complexity of this machine is quadratic in nature, and follows the following quadratic equation (where is the length of the input tape):
Therefore, we can conclude that the runtime complexity (both best- and worst-case) is for this Turing machine.
On the other hand, the space-complexity of this machine is linear in nature, and follows the following linear equation (where is the length of the input tape):
Therefore, we can conclude that the space complexity (both best- and worst-case) is for this Turing machine.