The Time and Space Complexity

Topics: Computational complexity theory, Analysis of algorithms, Big O notation Pages: 6 (1098 words) Published: July 28, 2013
TIME AND SPACE COMPLEXITY
Time Complexity
The total number of steps involved in a solution to solve a problem is the function of the size of the problem, which is the measure of that problem’s time complexity. some general order that we can consider

(c) < O(log n) < O(n) < O(n log n) < O(nc) < O(cn) < O(n!), where c is some constant. Space Complexity
Space complexity is measured by using polynomial amounts of memory, with an infinite amount of time. The difference between space complexity and time complexity is that space can be reused. Space complexity is not affected by determinism or nondeterminism. Amount of computer memory required during the program execution, as a function of the input size A small amount of space, deterministic machines can simulate nondeterministic machines, where as in time complexity, time increase exponentially in this case. A nondeterministic TM using O(n) space can be changed to a deterministic TM using only O2(n) space. Complexity: why bother?

Estimation/Prediction
When you write/run a program, you need to be able to predict its needs, its requirements.
Usual requirements
- execution time
- memory space
Quantities to estimate
execution time ( time complexity
memory space ( space complexity

It is pointless to run a program that requires:
- 6TeraB of RAM on a desktop machine;
- 10,000 years to run. . .
You do not want to wait for an hour:
- for the result of your query on Google;
- when you are checking your bank account online;
- when you are opening a picture file on Photoshop;
- etc.
( It is important to write efficient algorithms

Complexity Classes
| |Deterministic Polynomial Time | |P-complete |Hardest problems in P solvable on parallel computers | | |Nondeterministic polynomial time and YES answers checkable in polynomial time | |Co-NP |Nondeterministic polynomial time and NO answers checkable in polynomial time | |NP-complete |Hardest problems in NP | |Co-NP-complete |Hardest problems in CO-NP | |NP-hard |At least as hard as NP-complete problems | |NC |Solvable parallel computation efficiency | |PSPACE |Polynomial memory with unlimited time | |PSPACE-complete |Hardest problems in PSPACE | |EXPTIME |Exponential time | |EXPSPACE |Exponential memory with unlimited time | |BQP |Polynomial time on a quantum computer |

Find the greatest common divisor (GCD) of two integers, m and n.

Program (in C):
int gcd(int m, int n)
/* precondition: m>0 and n>0.Let g=gcd(m,n). */
{
while( m > 0 )
{ /* invariant: gcd(m,n)=g */
if( n > m )
{ int t = m; m = n;...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Space and Time Essay
  • Space Time Essay
  • Essay about Conquering Space and Time: the Telegraph
  • The Space and Time of Ulises Essay
  • Essay about Space and TIme
  • Space Time Essay
  • Computational Complexity Theory and Polynomial Time Essay
  • Essay about Its time

Become a StudyMode Member

Sign Up - It's Free