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

GATE 2005

203 questions

MCQ 2031-mark 203

Questions 96–100 of 203

Q96Array and Pointer1 markMCQ−0.33 if wrong
The following C function takes two ASCII strings and determines whether one is an anagram of the other. An anagram of a string s is a string obtained by permuting the letters in s.
int anagram (char *a, char *b) {
    int count [128], j;
    for (j = 0;  j < 128; j++) count[j] = 0;
    j = 0;
    while (a[j] && b[j]) {
        A;
        B;
    }
    for (j = 0; j < 128; j++) if (count [j]) return 0;
    return 1;
} 

Choose the correct alternative for statements A and B.

Q97Array1 markMCQ−0.33 if wrong
Let a and b be two sorted arrays containing n integers each, in non-decreasing order. Let c be a sorted array containing 2n integers obtained by merging the two arrays a and b. Assuming the arrays are indexed starting from 0, consider the following four statements

I. a[i]≥b[i]⇒c[2i]≥a[i]a[i] \geq b [i] \Rightarrow c[2i] \geq a [i]
II. a[i]≥b[i]⇒c[2i]≥b[i]a[i] \geq b [i] \Rightarrow c[2i] \geq b [i]
III. a[i]≥b[i]⇒c[2i]≤a[i]a[i] \geq b [i] \Rightarrow c[2i] \leq a [i]
IV. a[i]≥b[i]⇒c[2i]≤b[i]a[i] \geq b [i] \Rightarrow c[2i] \leq b [i]

Which of the following is TRUE?

Q98Array1 markMCQ−0.33 if wrong
A program P reads in 500 integers in the range [0,100] representing the scores of 500 students. It then prints the frequency of each score above 50. What would be the best way for P to store the frequencies?

Q99Stack1 markMCQ−0.33 if wrong
A function ff defined on stacks of integers satisfies the following properties. f(∅)=0f(\emptyset) = 0 and f(push(S,i))=max(f(S),0)+if (push (S, i)) = max (f(S), 0) + i for all stacks SS and integers ii. If a stack SS contains the integers 2, -3, 2, -1, 2 in order from bottom to top, what is f(S)f(S)?