Computer Science EngineeringHard
The best-case running time of insertion sort (already sorted input) is
- A. O(n^2)
- B. O(n log n)
- C. O(log n)
- D. O(n)
Correct answer: D. O(n)
Each element needs a single comparison, so the total is linear.
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- The recurrence T(n) = T(sqrt(n)) + 1 has the solution
- Prim's algorithm on a graph stored as an adjacency matrix with a simple array for minimum selection runs in
- The postfix form of the infix expression a + b c - d is
- The length of a longest common subsequence of ABCBDAB and BDCABA is
- The 0/1 knapsack problem with n items and capacity W is solved by dynamic programming in time
- A red-black tree with n internal nodes has height at most