edited by
165 views
2 2 votes

Which of the following is correct order of increasing time complexity of algorithms

  1. Tower of Hanoi with $n$ disk.
  2. Binary search given $n$ sorted numbers.
  3. Heap sort given $n$ numbers at the worst case.
  4. Addition of two $n \times n$ matrices.
Choose the correct answer from the options given below:
  1. $\text{II, III, IV, I}$
  2. $\text{I, II, III, IV}$
  3. $\text{IV, III, II, I}$
  4. $\text{III, I, IV, II}$

2 Answers

1 1 vote

As we know that the complexities are -->

AlgorithmComplexity
I. Tower of Hanoi (n disks)O(2ⁿ) — exponential
II. Binary Search (n sorted numbers)O(log n) — logarithmic
III. Heap Sort worst caseO(n log n) — linearithmic
IV. Addition of two n×n matricesO(n²) — quadratic



Now, we know that-->> Logarithmic < Linearithmic < Quadratic < Exponential 
So,
O(logn)<O(nlogn)<O(n2)<O(2n).
Correct Order: II, III, IV, I
Option A.

 

0 0 votes
option C is correct.

tower of hanoi = O(2^n )

binary serach = O(logn)

Heap sort = O(nlogn)

Addition of two matrix = O(n*n)

so option c is correct
Answer:
Position:
Show:

Related questions

0 0 votes
1 1 answer
842
842 views
soujanyareddy13 asked Jan 9, 2022
842 views
If a hash table is implemented as a search tree, the expected time required to enter $\text{n}$ names and make $\text{m}$ searches is proportional to :$\text{(n+m)} \log_...
3 3 votes
1 1 answer
266
266 views
Shubham Sharma 2 asked Apr 19
266 views
Which of the following is correct solution of the given recurrence relation? $T(n)=3 T(n / 4)+n \log n$$\theta(n \log n)$$\theta\left(n^{2} \log n\right)$$\theta\left(n(\...
0 0 votes
1 1 answer
124
124 views
Shubham Sharma 2 asked Apr 19
124 views
Match the LIST-I with LIST-IILIST-ILIST-IIA.Dynamic programmingI.Floyd Warshall Shortest pathB.GreedyII.Huffman codingC.Back trackingIII.Hamiltonian cycle problemD.Branch...
0 0 votes
1 1 answer
91
91 views
Shubham Sharma 2 asked Apr 19
91 views
What is the space complexity of the CYK algorithm for the $\mathrm{P}$ table, where $\mathrm{n}$ is the number of words in the sentence and $\mathrm{m}$ is the number of ...