Docsity

Complexity Theory, Lecture notes of Theory of Computation

Partial preview of the text

Download Complexity Theory and more Lecture notes Theory of Computation in PDF only on Docsity!

Complexity Theory

Part One

Complexity Theory

It may be that since one is customarily

concerned with existence, […] finiteness,

and so forth, one is not inclined to take

seriously the question of the existence of a

better-than-finite algorithm.

  • Jack Edmonds, “Paths, Trees, and Flowers”

It may be that since one is customarily

concerned with existence, […] decidability,

and so forth, one is not inclined to take

seriously the question of the existence of a

better-than-decidable algorithm.

  • Jack Edmonds, “Paths, Trees, and Flowers”

For Reference ●

Assume c = 1.

2 0 = 2 2 2 1 = 4 2 2 2 = 16 2 2 3 = 256 2 2 4 = 65536 2 2 5 = 18446744073709551616 2 2 6 = 340282366920938463463374607431768211456

The Limits of Decidability ●

The fact that a problem is decidable does not

mean that it is feasibly decidable.

●

In computability theory , we ask the question

What problems can be solved by a computer?

●

In complexity theory , we ask the question

What problems can be solved

efficiently by a computer?

●

In the remainder of this course, we will

explore this question in more detail.

The Setup ●

In order to study computability, we

needed to answer these questions:

● What is “computation?” ● What is a “problem?” ● What does it mean to “solve” a problem? ●

To study complexity, we need to answer

these questions:

● What does “complexity” even mean? ● What is an “efficient” solution to a problem?

Measuring Complexity ● (^) Suppose that we have a decider D for some language L. ● How might we measure the complexity of D? Number of states. Size of tape alphabet. Size of input alphabet. Amount of tape required. ● (^) Amount of time required. Number of times a given state is entered. Number of times a given symbol is printed. Number of times a given transition is taken. (Plus a whole lot more...)

Searching Finite Spaces ●

Many decidable problems can be solved by

searching over a large but finite space of

possible options.

●

Searching this space might take a

staggeringly long time, but only finite time.

●

From a decidability perspective, this is totally

fine.

●

From a complexity perspective, this is totally

unacceptable.

A Sample Problem 4 3 11 9 7 13 5 6 1 12 2 8 0 10 Goal: Find the length of the longest increasing subsequence of this sequence. Goal: Find the length of the longest increasing subsequence of this sequence.

Longest Increasing Subsequences ● One possible algorithm: try all subsequences, find the longest one that's increasing, and return that. ● There are 2 n^ subsequences of an array of length n. ● (Each subset of the elements gives back a subsequence.) ● Checking all of them to find the longest increasing subsequence will take time O( n · 2 n ). ● Nifty fact: the age of the universe is about 4.3 × 10^26 nanoseconds old. That's about 2^85 nanoseconds. ● Practically speaking, this algorithm doesn't terminate if you give it an input of size 100 or more.

Longest Increasing Subsequences ● Theorem: There is an algorithm that can find the longest increasing subsequence of an array in time O( n log n ). ● The algorithm is beautiful and surprisingly elegant. Look up patience sorting if you're curious. ● This algorithm works by exploiting particular aspects of how longest increasing subsequences are constructed. It's not immediately obvious that it works correctly.

Shortest Paths ●

It is possible to find the shortest path in a

graph by listing off all sequences of

nodes in the graph in ascending order of

length and finding the first that's a path.

●

This takes time O( n · n !) in an n -node

graph.

●

For reference: 29! nanoseconds is longer

than the lifetime of the universe.

Shortest Paths ● Theorem: It's possible to find the shortest path between two nodes in an n -node, m - edge graph in time O( m + n ). ● This is the breadth-first search algorithm. Take CS106B/X or CS161 for more details! ● The algorithm is a bit nuanced. It uses some specific properties of shortest paths and the proof of correctness is nontrivial.