Computer Sciences > GATE 2026 SET-2 > Algorithms
Consider an array 𝐴 of integers of size 𝑛. The indices of 𝐴 run from 1 to 𝑛. An algorithm is to be designed to check whether 𝐴 satisfies the condition given below.
∀𝑖,𝑗∈{1,…,𝑛−1} such that 𝑖>𝑗,(𝐴[𝑖+1]−𝐴[𝑖])> (𝐴[𝑗+1]−𝐴[𝑗])
Which one of the following gives the worst case time complexity of the fastest algorithm that can be designed for the problem?
A
Θ(n)
B
Θ(log n)
C
Θ(n log n)
D
Θ(n²)

Correct : a

The correct answer is Option A - Θ(n).
We just need to check if the differences between consecutive elements are strictly increasing.
Compute di = Ai+1 − Ai, and compare each difference with the next one.
Traverse the array once, and for each i, check if:
(Ai+1 − Ai) < (Ai+2 − Ai+1).
If any condition fails, return false. If all checks pass, return true.
This takes one linear scan of the array.
Time Complexity: Θ(n), since we process each element once.

Similar Questions

Match the following (P) Prim’s algorithm for minimum spanning tree (i) Backtracking (Q) Floyd-Warshall algorithm fo...
#82 MCQ
Consider the following table Algorithms Design Paradigms (P) Kruskal (i) Divide and Conquer...
#203 MCQ
Consider functions Function 1 and Function 2 expressed in pseudocode as follows: Let f1(n) and f2(n) denote the number of times the statement "x = x + 1" is...
#989 MSQ

Related Topics

GATE 2026 GATE CS 2026 Set 2 GATE CS 2026 Q38 time complexity GATE strictly increasing differences array differences GATE fastest algorithm GATE algorithms GATE 2026 Θ(n) time complexity consecutive differences check GATE CS algorithms question

Unique Visitor Count

Total Unique Visitors

Loading......