GATE 2003 Computer Science and Information Technology (CS) Questions with Solutions

GATE 2003

107 questions

MCQ 1071-mark 107

Questions 56–60 of 107

Q56Array and Pointer1 markMCQ−0.33 if wrong
In the following C program fragment, j, k, n and TwoLog_n are integer variables, and A is an array of integers. The variable n is initialized to an integer ≥\geq 3, and TwoLog_n is initialized to the value of 2∗⌈log2n⌉2*\left \lceil log_{2}n \right \rceil
 for (k = 3; k <= n; k++)
    A[k] = 0;
for (k = 2; k <= TwoLog_n; k++)
    for (j = k + 1; j <= n; j++)
        A[j] = A[j] || (j % k);
for (j = 3; j <= n; j++)
    if (!A[j]) printf("%d", j);
The set of number printed by this program fragment is

Q57Array and Pointer1 markMCQ−0.33 if wrong
Assume the following C variable declaration
int *A [10], B[10][10];
Of the following expressions
I A[2]
II A[2][3]
III B[1]
IV B[2][3]
which will not give compile-time errors if used as left hand sides of assignment statements in a C program?

Q58Stack1 markMCQ−0.33 if wrong
Let S be a stack of size n ≥\geq 1. Starting with the empty stack, suppose we push the first n natural numbers in sequence, and then perform n pop operations. Assume that Push and Pop operation take X seconds each , and Y seconds elapse between the end of the one such stack operation and the start of the next operation. For m ≥\geq 1, define the stack-life of m as the time elapsed from the end or Push (m) to the start of the pop operation that removes m from S . The average stack-life of an element of this stack is

Q60Binary Search Tree1 markMCQ−0.33 if wrong
Suppose the numbers 7, 5, 1, 8, 3, 6, 0, 9, 4, 2 are inserted in that order into an initially empty binary search tree. The binary search tree uses the usual ordering on natural numbers. What is the inorder transversal sequence of the resultant tree ?