Skip to main content

How to calculate TIME COMPLEXITY of any program || How TIME COMPLEXITY of an algorithm is computed .


The time tp,taken by a program P ,, is the sum of the Compile time and the Run time(execution time) .The Compile time doesn't depends on the instance characteristics (it emplies..>>number of input,number of output,magnitude of input,magnitude of output). Thus we are concered with the running time of a program only.

Algorithm_X(a,b,c) { return a-b+c+b*c+(a+b+c/3)+b; } Here the problem instance is characterized by the specified values of a,b and c. This run time is denoted by tp,We have:
tp(n) = CaADD(n) + CsSUB(n) + CmMUL(n) + CdDIV(n)+....
Where n-->instance characteristics. Ca,Cssub>,+ Cm,Cd denotes the time needed for Addition,Subtraction,Multiplication,Division and so on.

Following are the primitive operations that are independent from the programming language are used to calculate the running time :

  • Assigning a value to a variable.
  • Calling a function.
  • Performing an arithmetic operation.
  • Comparing two variables.
  • Indexing into a array of following a pointer reference.
  • Returning from a function.


Quote: All our dreams can come true, if we have the courage to pursue them...|| Believe in yourself. You are braver than you think, more talented than you know, and capable of more than you imagine...|| Believe in yourself, take on your challenges, dig deep within yourself to conquer fears. Never let anyone bring you down. You got to keep going...||