1
GATE CSE 2008
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C program that attempts to locate an element x in an array Y[] using binary search. The program is erroneous.
1. f(int Y[10], int x) {
2. int i, j, k;
3. i = 0; j = 9;
4. do {
5. k = (i + j) /2;
6. if( Y[k] < x) i = k; else j = k;
7. } while(Y[k] != x && i < j);
8. if(Y[k] == x) printf ("x is in the array ") ;
9. else printf (" x is not in the array ") ;
10. }
The correction needed in the program to make it work properly is 2
GATE CSE 2008
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C program that attempts to locate an element x in an array Y[] using binary search. The program is erroneous.
1. f(int Y[10], int x) {
2. int i, j, k;
3. i = 0; j = 9;
4. do {
5. k = (i + j) /2;
6. if( Y[k] < x) i = k; else j = k;
7. } while(Y[k] != x && i < j);
8. if(Y[k] == x) printf ("x is in the array ") ;
9. else printf (" x is not in the array ") ;
10. }
On which of the following contents of Y and x does the program fail?3
GATE CSE 2008
MCQ (Single Correct Answer)
+2
-0.6
The subset-sum problem is defined as follows. Given a set of n positive integers, S = {a1 ,a2 ,a3 ,…,an} 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 <= i <= n, 0 <= j <= W, is TRUE if and only if there is a subset of {a1 ,a2 ,…,ai} whose elements sum to j.
Which entry of the array X, if TRUE, implies that there is a subset whose elements sum to W?
Which entry of the array X, if TRUE, implies that there is a subset whose elements sum to W?
4
GATE CSE 2008
MCQ (Single Correct Answer)
+2
-0.6
The subset-sum problem is defined as follows. Given a set of n positive integers, S = {a1 ,a2 ,a3 ,…,an} 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 <= i <= n, 0 <= j <= W, is TRUE if and only if there is a subset of {a1 ,a2 ,…,ai} whose elements sum to j.
Which of the following is valid for 2 <= i <= n and ai <= j <= W?
Which of the following is valid for 2 <= i <= n and ai <= j <= W?
Paper analysis
Total Questions
Algorithms
15
Compiler Design
4
Computer Networks
7
Computer Organization
9
Data Structures
9
Database Management System
12
Digital Logic
3
Discrete Mathematics
30
Operating Systems
7
Programming Languages
3
Theory of Computation
9
More papers of GATE CSE
GATE CSE 2024 Set 2
GATE CSE 2024 Set 1
GATE CSE 2023
GATE CSE 2022
GATE CSE 2021 Set 2
GATE CSE 2021 Set 1
GATE CSE 2020
GATE CSE 2019
GATE CSE 2018
GATE CSE 2017 Set 1
GATE CSE 2017 Set 2
GATE CSE 2016 Set 1
GATE CSE 2016 Set 2
GATE CSE 2015 Set 1
GATE CSE 2015 Set 3
GATE CSE 2015 Set 2
GATE CSE 2014 Set 3
GATE CSE 2014 Set 2
GATE CSE 2014 Set 1
GATE CSE 2013
GATE CSE 2012
GATE CSE 2011
GATE CSE 2010
GATE CSE 2009
GATE CSE 2008
GATE CSE 2007
GATE CSE 2006
GATE CSE 2005
GATE CSE 2004
GATE CSE 2003
GATE CSE 2002
GATE CSE 2001
GATE CSE 2000
GATE CSE 1999
GATE CSE 1998
GATE CSE 1997
GATE CSE 1996
GATE CSE 1995
GATE CSE 1994
GATE CSE 1993
GATE CSE 1992
GATE CSE 1991
GATE CSE 1990
GATE CSE 1989
GATE CSE 1988
GATE CSE 1987
GATE CSE
Papers
2023
2022
2020
2019
2018
2013
2012
2011
2010
2009
2008
2007
2006
2005
2004
2003
2002
2001
2000
1999
1998
1997
1996
1995
1994
1993
1992
1991
1990
1989
1988
1987