GATE CS 2008 · Asymptotic Analysis & Recurrences

MCQ · 2 marks · Problem PROG-DIVC-0123

The subset-sum problem is defined as follows. Given a set of n positive integers, S={\(a_{1},a_{2},...,a_{n}\)} and positive integer W, is there a subset of S whose elements sum to W? A dynamic program for solving this problem uses a 2-dimensional Boolean array, X, with n rows and W+1 columns. X[i,j], \(1\leq i\leq n\), \(0\leq j \leq W\), is TRUE if and only if there is a subset of {\(a_{1},a_{2},...,a_{i}\)}whose elements sum to j. Which entry of the array X, if TRUE, implies that there is a subset whose elements sum to W?
  1. A
    X[1,W]
  2. B
    X[n,0]
  3. C
    X[n,W]
  4. D
    X[n-1,n]

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

Show the worked solutionOfficial GATE Answer Key: Option C.See full step-by-step discussion on GateOverflow: https://gateoverflow.in/43484/gate2008-81

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