Question
Consider an array of integers of size . The indices of run from to . An algorithm is to be designed to check whether satisfies the condition given below.
Which one of the following gives the worst case time complexity of the fastest algorithm that can be designed for the problem?
Official answer and solution
- Official answer
- A
- From
- Official GATE 2026 answer key
Solution
Observe that the condition simply states that the adjacent difference sequence is strictly increasing.
Let for . By transitivity of , the condition for all holds if and only if for every consecutive index . We can verify this in a single pass over the array in time, and in the worst case every element of must be inspected at least once (). Therefore, the optimal worst-case time complexity is .
Option (A)
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2026 Computer Science and Information Technology - Session 2 (CS2)
- Question
- 38 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.