Ethio-Lens College Complexity Theory Lecture Notes, Department CS, Class Year IV 1. Introduction To Complexity Theory
Ethio-Lens College Complexity Theory Lecture Notes, Department CS, Class Year IV 1. Introduction To Complexity Theory
Ethio-Lens College Complexity Theory Lecture Notes, Department CS, Class Year IV 1. Introduction To Complexity Theory
1|Page
because a double sized dictionary only has to be opened one time more (e.g. exactly in the
middle then the problem is reduced to the half).
1.2 Examples of Problems
A simple problem, familiar to most school children, namely that of adding two numbers. Say
10234843 to the number 2345639. Then starting with the rightmost column, you add the two
digits in the column. If this leads to a number less than ten, then write the number below the two
digits and repeat on the next column to the left, else write the last digit of the sum below the two
digits, and then repeat with the next column to the left, retaining a carry of 1. The description
above is roughly what an algorithm is.
Analysis" of the above \algorithm" for adding numbers. Suppose the numbers to be added are
each at most n digits long, then how many simple steps does computing their sum take? you may
say it takes about n steps (one for each column of the input) or n + 1 steps (to write down the
possibly n + 1 digits of the output) or 5n + 1 steps where each column of the input took at most
five elementary calculations (adding the digits, adding the carry-in if necessary, seeing if the sum
is less than ten or more, splitting the result into two digits, writing the lesser digit and moving the
rest into the carry) and the final column of the output took one step. No matter the steps, it has
linear form, a.n+b. where a and b are some constants. What is important is that the answer can
not be found in less than n steps (not say root(n) steps which would be much smaller than n) nor
does it require n2 steps. This leads to a crude, but extremely useful, approximation to the time
complexity of this algorithm - it takes Q(n) steps (where Q(n) roughly suppresses the a and the b
above and other such \lesser order terms" and just describes the leading term).
b. Problem 2: Multiplication. Now lets consider a somewhat more complex \computational
problem", that of multiplying two numbers. So the input to the task is two numbers, say X and
Y , each at most n digits long. The goal of the task is to produce or \output" the product X x Y ,
the result of multiplying X and Y . XxY=X+X… Y number of copies..If X&Y are n digtis long,
then require 10n additions. (for ten digits requires n*10n =10*1010 =100 Billion steps too slow)
The quicker one is, This is the method which roughly computes n numbers, the first being the
product of X with the least significant digit of Y , the second being the product of X with its ten
times its next signicant digits and so on, and then adds these n numbers together. Which
computes, in Q(n2) steps, in this case 100 steps for ten digit numbers, but take much more time
2|Page
than adding two numbers. But no algorithm found that can compute in linear time Q(n) since
multiplication is more complex than addition.
Computational complexity
Two very broad classes of running time complexity that turn out to take a central role in
computing are \polynomial time computable problems" (also known by the single letter P) and
\exponential time computable problems". The former include all problems that can be solved in
time Q(nC) for some constant c (independent of the input size n), while the latter is a broader
class and includes all functions that can be solved in time 2Q(nc) for constant c.
To understand the difference between the two cases, consider some problem X whose
complexity is in P (polynomial time). Let n0 be the largest input length for which this problem
can be solved in an hour on a computer. Now suppose we double the amount of time available.
How will the size of the largest solvable input grow? The feature of P is that this input size will
grow by a constant multiplicative factor. For problems with algorithms in time Q(n), the n0 will
double. For problems with algorithms in time Q(n3), the n0 will only grow by a factor of cub root
2 . If this seems bad, now consider what happens to a problem that is only solvable in xponential
time. For such a problem the corresponding input length would only grow additively, when the
running time grows by a multiplicative factor. Indeed for algorithms running in time 2n, doubling
the running time only adds 1 to n0.
Complexity classes
Complexity Classes
o A complexity class is the set of all of the computational
problems which can be solved using a certain amount of a certain computational resource.
o The complexity class P is the set of decision problems that can be solved by a deterministic
machine in polynomial time. This class corresponds to an intuitive idea of the problems which
can be effectively solved in the worst cases.
o The complexity class NP is the set of decision problems that can be solved by a
nondeterministic machine in polynomial time. This class contains many problems that people
would like to be able to solve effectively. All the problems in this class have the property that
their solutions can be checked effectively.
Complexity Class P
3|Page
P is the class already described informally above, i.e., all computational problems that can be
solved in polynomial time. (Strictly speaking the class P only contains computational
problems described by Boolean functions, i.e., by functions whose output is either 0 or 1, but
the difference is not significant to this article.)
o P is the complexity class containing decision problems which can be solved by a deterministic
Turing machine using a polynomial amount of computation time, or polynomial time.
o P is often taken to be the class of computational problems which are "efficiently solvable" or
"tractable“. Problems that are solvable in theory, but cannot be solved in practice, are called
intractable.
o There exist problems in P which are intractable in practical terms; for example, some require at
least n 1000000 operations.
o P is known to contain many natural problems, including the decision versions of linear
programming, calculating the greatest common divisor, and finding a maximum matching. In
2002, it was shown that the problem of determining if a number is prime is in P.
Complexity Class NP
4|Page
colorable with 3 colors and false otherwise. The search problem would ask for a coloring of the
nations with the three colors when the decision version returns true.
5|Page
2.1 Introduction
6|Page
P problems can be solved efficiently, can easily develop algorithms; NP are problems
whose solutions can be verified efficiently. Can be solved by an inefficient manner, if
some one gave us the solution, but easy to check whether solution is correct or not.
2.4 NL completeness
7|Page
3. Circuit Complexity
8|Page
9|Page
4. Polynomial Hierarchy
4.1 Polynomial Hierarchy
10 | P a g e
5. Randomized computations
11 | P a g e
12 | P a g e