PREVIOUS YEAR SOLVED PAPERS - GATE 2018

36. Consider the following C program:
#include
void fun 1 (char *s1, char *s2) {
char *tmp;
tmp = s1;
s1 = s2;
s2 = tmp;
}
Void fun2 (char **s1, char **s2) {
char *tmp;
tmp = s1;
s1 = s2;
s2 = tmp;
}
int main () {
char *str1 = “Hi”, *str2 = “Bye”;
fun1 (str1, str2);
printf(“%s %s”, str1, str2);
fun2 (&str1, &str2);
printf(“%s %s”, str1, str2);
return 0;
}
The output of the program above is

  • Option : A
  • Explanation :
    fun1(char *s1, char *s2)
    function scope is local, so the value changed So the affect actual parameters. SO the values will be ‘Hi Bye’.
    fun2(char **s1, char **s2)
    In this function value is pointer to pointer, so it changes pointer of the actual value. So values will be ‘Bye Hi’
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


37. Consider the first-order logic sentence
φ ≡ ∃s∃t∃u∀v∀w∀x∀y ψ(s, t, u, v, w, x, y)
where ψ(s, t, u, v, w, x, y) is a quantifier-free first-order logic formula using only predicate symbols, and possibly equality,
but no function symbols. Suppose φ has a model with a universe containing 7 elements.
Which one of the following statements is necessarily true?

  • Option : A
  • Explanation :
    ∀ are always True and ∃ are always False for empty sets.
    So there exists at least one model with universe of size 3 (or less than). Therefore, option (A) is necessarily TRUE.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


38. Let G be a simple undirected graph. Let TD be a depth first search tree of G. Let TB be a breadth first search tree of G. Consider the following statements.
(I) No edge of G is a cross edge with respect to TD. (A cross edge in G is between two nodes neither of which is an ancestor of the other in TD).
(II) For every edge (u, v) of G, if u is at depth i and v is at depth j in TB, then ∣i − j∣ = 1.
Which of the statements above must necessarily be true?

  • Option : A
  • Explanation :
    For statement (II) take counter example of complete graph of three vertices, i.e., K3 with XYZ, where X is source and Y and Z are in the same level. Also, there is an edge between vertices Y and Z, i.e., |i-j| = 0 ≠ 1 in BFS. So, statement became false. Option (A) is correct.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


39. The size of the physical address space of a processor is 2P bytes. The word length is 2W bytes. The capacity of cache memory is 2N bytes. The size of each cache block is 2M words. For a K-way set-associative cache memory, the length (in number of bits) of the tag field is

  • Option : B
  • Explanation :
    MM space = 2P bytes
    Physical Address (PA) size = P bits
    CM size = 2N bytes
    Block size 2M words
    2M words*2W bytes/word
    2M+W bytes
    Number of lines = (CM size)/Block size ⇒ 2N/(2M+W)
    ⇒ 2N-M-W
    Number of sets = (Number in cm)/P-way
          = 2N-M-W/K
    The Address format

    ⇒ (N-M-W-log2K)
    ∴ Tag size
    ⇒ P-(N-M-W-log2K)
    ⇒ P-N+log2K)
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


40. Consider the following problems. L(G) denotes the language generated by a grammar G. L(M) denotes the language accepted by a machine M.
(I) For an unrestricted grammar G and a string w, whether wϵL(G)
(II) Given a Turing machine M, whether L(M) is regular
(III) Given two grammar G1 and G2, whether L(G1) = L(G2)
(IV) Given an NFA N, whether there is a deterministic PDA P such that N and P accept the same language
Which one of the following statement is correct?

  • Option : D
  • Explanation :
    Here the match flowing.
    I. Membership problem for RE → undecidable
    II. Regularity problem for RE → undecidable
    III. Equivalence problem for RE → undecidable
    IV. Since DPDA P exists for every nfa N and equivalent to it, this problem is trivially decidable.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


Related Quiz.
GATE 2018