Complexity Flashcards

(37 cards)

1
Q

What does computational complexity measure?

A

The number of steps a Turing machine takes to compute an output.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How is complexity formally defined?

A

As the number of steps a Turing machine implementation of an algorithm takes before halting.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the time complexity of a machine that deletes all input symbols aⁿ?

A

C(n) = 2n + 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the time complexity of a machine that checks if aⁿ is even or odd?

A

C(n) = n + 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why is the initial definition of TM complexity problematic?

A

Because TMs might not halt, vary across inputs of same length, and are sensitive to implementation details.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do we fix non-halting machines in complexity theory?

A

Restrict attention to total computable functions (TMs that halt on all inputs).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do we handle variation between inputs of the same length?

A

Use worst-case time complexity: C_M(n) = max steps for all |w| = n.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do we handle differences in low-level implementation?

A

Use Big-O notation to abstract away constant and linear differences.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does f(n) = O(g(n)) mean?

A

There exist constants c and n₀ such that f(n) ≤ c·g(n) for all n ≥ n₀.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Why use Big-O notation in complexity?

A

To express machine-independent growth rates of time requirements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the formal definition of time complexity of a decision problem?

A

A language L has time complexity O(g(n)) if some TM decides L and halts in ≤ O(g(n)) steps on inputs of length n.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is worst-case time complexity?

A

The maximum number of steps a machine takes on any input of a given length.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is average-case time complexity?

A

The expected number of steps taken on a randomly chosen input.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is space complexity?

A

The number of tape cells used by a Turing machine on a given input.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does it mean for a TM to be total?

A

It halts on all possible inputs — required for complexity analysis.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is an example of a language with O(n²) complexity?

A

Palindrome checking: L = { w | w = w^R }

17
Q

Why is palindrome checking O(n²)?

A

Because each comparison step may involve a scan across the whole string, summing to n(n+1)/2.

18
Q

What is the benefit of using Big-O over raw step counts?

A

It abstracts away constant factors and minor variations for generality and comparison.

19
Q

What does the complexity class P represent?

A

The class of problems that can be decided by a deterministic Turing machine in polynomial time.

20
Q

What does it mean for a problem to be in P?

A

It can be solved efficiently — in O(n^d) time for some d ≥ 0.

21
Q

What are some common time complexity classes?

A

O(1), O(log n), O(n), O(n²), O(n^d), O(2^n), O(n!)

22
Q

Is primality testing in P?

A

Yes — the AKS algorithm showed it can be done in polynomial time.

23
Q

What breakthrough occurred in 2004 related to primality?

A

Agrawal, Kayal, and Saxena proved that primality is in P (PRIMES is in P).

24
Q

What is the TSP (Travelling Salesperson Problem)?

A

Find whether a tour visiting all cities once with total cost ≤ L exists.

25
What is the complexity of a naive TSP solution?
O(n!) — exponential time, not polynomial.
26
What is a nondeterministic Turing machine (NTM)?
A machine that can guess a string and verify it in polynomial time.
27
How does an NTM accept a string?
If there exists some guess that leads to acceptance.
28
What does the complexity class NP represent?
Problems for which a solution can be verified in polynomial time by a Turing machine.
29
Is TSP in NP?
Yes — because a guessed tour can be verified in polynomial time.
30
What is the relationship between P and NP?
P ⊆ NP — all problems solvable in polynomial time are also verifiable in polynomial time.
31
Can all problems in NP be solved in exponential time?
Yes — using a brute-force deterministic Turing machine (not efficient).
32
What is the P vs NP problem?
The open question of whether every problem whose solution can be verified in polynomial time can also be solved in polynomial time.
33
Why is P vs NP significant?
Solving it would revolutionize cryptography, optimization, and theorem proving.
34
What happens if P = NP?
Many currently hard problems become efficiently solvable — massive implications for security and computation.
35
Why hasn't P ≠ NP been proven?
We lack a general method to show that no polynomial-time algorithm exists for NP problems.
36
What class do feasible decision problems usually belong to?
Class P — solvable in polynomial time.
37
What kind of problems are in NP but not known to be in P?
Problems like SAT, TSP, clique detection, and many optimization problems.