1
GATE CSE 2007
MCQ (Single Correct Answer)
+2
-0.6
Suppose you are given an implementation of a queue of integers. The operations that can be performed on the queue are:
i. isEmpty (Q) — returns true if the queue is empty, false otherwise.
ii. delete (Q) — deletes the element at the front of the queue and returns its value.
iii. insert (Q, i) — inserts the integer i at the rear of the queue.
Consider the following function:
i. isEmpty (Q) — returns true if the queue is empty, false otherwise.
ii. delete (Q) — deletes the element at the front of the queue and returns its value.
iii. insert (Q, i) — inserts the integer i at the rear of the queue.
Consider the following function:
void f (queue Q) {
int i ;
if (!isEmpty(Q)) {
i = delete(Q);
f(Q);
insert(Q, i);
}
}
What operation is performed by the above function f ? 2
GATE CSE 2007
MCQ (Single Correct Answer)
+2
-0.6
The following postfix expression with single digit operands is evaluated using a stack:
8 2 3 ^ / 2 3 * + 5 1 * -
Note that ^ is the exponentiation operator. The top two elements of the stack after the first * is evaluated are:
3
GATE CSE 2007
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C program:
#include
#define EOF -1
void push (int); /* push the argument on the stack */
int pop (void); /* pop the top of the stack */
void flagError ();
int main () {
int c, m, n, r;
while ((c = getchar ()) != EOF) {
if (isdigit (c) )
push (c);
else if ((c == '+') || (c == '*')) {
m = pop ();
n = pop ();
r = (c == '+') ? n + m : n*m;
push (r);
} else if (c != ' ')
flagError ();
}
printf("% c", pop ());
}
What is the output of the program for the following input ?
5 2 * 3 3 2 + * + 4
GATE CSE 2006
MCQ (Single Correct Answer)
+2
-0.6
The following function computes the value of mCn correctly for all legal values m and n (m≥1,n≥0 and m>n)
int func(int m, int n)
{
if (E) return 1;
else return(func(m -1, n) + func(m - 1, n - 1));
}
In the above function, which of the following is the correct expression for E?Questions Asked from Stacks and Queues (Marks 2)
Number in Brackets after Paper Indicates No. of Questions
GATE CSE Subjects
Theory of Computation
Operating Systems
Algorithms
Database Management System
Data Structures
Computer Networks
Software Engineering
Compiler Design
Web Technologies
General Aptitude
Discrete Mathematics
Programming Languages