GATE CS 2024 · Set-1 · Asymptotic Analysis & Recurrences

MCQ · 1 mark · Problem PROG-DIVC-0073

Given an integer array of size \(N\), we want to check if the array is sorted (in either ascending or descending order). An algorithm solves this problem by making a single pass through the array and comparing each element of the array only with its adjacent elements. The worst-case time complexity of this algorithm is
  1. A
    both \(\mathrm{O}(N)\) and \(\Omega(N)\)
  2. B
    \(\mathrm{O}(N)\) but not \(\Omega(N)\)
  3. C
    \(\Omega(N)\) but not \(\mathrm{O}(N)\)
  4. D
    neither \(\mathrm{O}(N)\) nor \(\Omega(N)\)

Solve it on GATE DA practice →More Searching & Sorting Algorithms problems

Show the worked solutionOfficial GATE Answer Key: Option A.See full step-by-step discussion on GateOverflow: https://gateoverflow.in/422835/gate-cse-2024-set-1-question-7

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com