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…
- A.
(i) > (ii) > (iii) > (iv)
- B.
(iv) > (iii) > (ii) > (i)
- C.
(ii) > (i) > (iii) > (iv)
- 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)