Question 31
int n, rev;
rev = 0;
while (n > 0)
{
rev = rev*10 + n%10;
n = n/10;
}
Question 32
Consider the following C program segment:
char p[20];
char *s = \"string\";
int length = strlen(s);
int i;
for (i = 0; i < length; i++)
p[i] = s[length — i];
printf(\"%s\",p);
The output of the program is (GATE CS 2004)
Question 34
(i) preorder and postorder (ii) inorder and postorder (iii) preorder and inorder (iv) level order and postorder
Question 35
Question 36
Question 37
Assume that the operators +, -, × are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, x , +, -. The postfix expression corresponding to the infix expression a + b × c - d ^ e ^ f is
Question 38
Question 39
Suppose each set is represented as a linked list with elements in arbitrary order. Which of the operations among union, intersection, membership, cardinality will be the slowest?
Question 40
main()
{
int x, y, m, n;
scanf (\"%d %d\", &x, &y);
/* Assume x > 0 and y > 0 */
m = x;
n = y;
while (m! = n)
{
if (m > n)
m = m - n;
else
n = n - m;
}
print f (\"% d\", n);
}
There are 90 questions to complete.