Complexity - Algorithm running time

7 important questions on Complexity - Algorithm running time

On what [4] things does algorithm running time depend?

  1. Problem size/input size;
  2. The algorithm used;
  3. Software compiler;
  4. Computer;

What are [2] assumptions in calculation of algorithm running times?

  1. Each number requires one symbol;
  2. Ideal computer that uses fixed time per elementary operation;

What are elementary operations?

+, -, *, /
  • Higher grades + faster learning
  • Never study anything twice
  • 100% sure, 100% understanding
Discover Study Smart

What is the definition of the algorithm running time?

The algorithm running time is an upper bound to the number of elementary operations that the algorithm needs for any input, as a function of the input size n.

When does an algorithm running time belong to an easy problem and when to a hard problem considering the following;

  • n 2
  • 2 n

n 2 | an easy problem
2 n | Hard problem

Give the algorithm running time of the following for sorting algorithms
  • Bubble sort;
  • Quick sort;
  • Shell sort;  
  • Heap sort;

Bubble sort | O(n 2 )
Quick sort | O(n 2 )
Shell sort | O(n 3/2 )
Heap sort | O(n log n)

What are the 2 algorithm running times rules and what do they imply

Addition rule
If an algorithm consists of 2 sub algorithms with running times O(f(n)) and O(g(n)) then, running time = O(max{f(n), g(n)})

Product rule
If an algorithm running time consists of executing O(f(n)) times a subroutine with running time (O(g(n)) then,
running time = O(f(n)*g(n))

The question on the page originate from the summary of the following study material:

  • A unique study and practice tool
  • Never study anything twice again
  • Get the grades you hope for
  • 100% sure, 100% understanding
Remember faster, study better. Scientifically proven.
Trustpilot Logo