Which of the following is associated with the highest time complexity? (i).…

Which of the following is associated with the highest time complexity?

(i). Permutations of a string.

(ii). Towers of Hanoi

(iii). Matrix multiplication

(iv). Finding an element in a binary search tree

Answer: A. (i) > (ii) > (iii) > (iv)Explanation: (i). Permutations of a string time complexity is O(n!) (ii). Towers of Hanoi time complexity is O(2^n) (iii). Matrix multiplication time…

  1. A.

    (i) > (ii) > (iii) > (iv)

  2. B.

    (iv) > (iii) > (ii) > (i)

  3. C.

     (ii) > (i) > (iii) > (iv)

  4. D.

     (i) > (ii) > (iv) > (iii)

Attempted by 183 students.

Show answer & explanation

Correct answer: A

Explanation:

(i). Permutations of a string time complexity is O(n!)

(ii). Towers of Hanoi time complexity is O(2^n)

(iii). Matrix multiplication time complexity is O(n^3)

(iv). Finding an element in a binary search tree time complexity is O(logn)

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…