GATE CS 2006 · Arrays & Matrix Representation

MCQ · 1 mark · Problem PROG-DSTR-0210

Given two arrays of numbers \(a_{1},...,a_{n}\) and \(b_{1},...,b_{n}\) where each number is 0 or 1, the fastest algorithm to find the largest span(i,j) such that \(a_{i}+a_{i+1}+...+a_{j}=b_{i}+b_{i+1}+.....+b_{j}\) , or report that there is no such span,
  1. A
    Takes \(O(3^{n})\) and \(\Omega (2^{n})\) time if hashing is permitted
  2. B
    Takes \(O(n^{3})\) and \(\Omega (n^{2.5})\) time in the key comparison model
  3. C
    Takes \(\Theta (n)\) time and space
  4. D
    Takes \(O(\sqrt{n})\) time only if the sum of the 2n elements is an even number

Solve it on GATE DA practice →More Basic Data Structures problems

Show the worked solutionOfficial GATE Answer Key: Option C.See full step-by-step discussion on GateOverflow: https://gateoverflow.in/1832/gate2006-54

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