1
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 + * + 2
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?3
GATE CSE 2006
MCQ (Single Correct Answer)
+2
-0.6
An implementation of a queue Q, using two stacks S1 and S2, is given below:
void insert(Q, X){
push(S1, X);
}
void delete(Q){
if(stack - empty(S1)) then {
print("Q is empty");
return;
}else while (!(stack - empty(S1))){
X = pop(S1);
push(S2, X);
}
X = pop(S2);
}
Let n insert and $$m( \le n)$$ delete operations be performed in an arbitrary order on an empty queue Q. Let x and y be the number of push and pop operations performed respectively in the process. Which one of the following is true for all m and n?4
GATE CSE 2004
MCQ (Single Correct Answer)
+2
-0.6
Assume that the operators +, -, ×, are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, ×, +, -. The postfix expression corresponding to the infix expression a + b×c-d^e^f is
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