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

GATE 2023

65 questions

MCQ 34 · MSQ 15 · NAT 161-mark 30 · 2-mark 35

Questions 56–60 of 65

Q56Graph Traversal (BFS and DFS)2 marksNAT
Let U={1,2,3}U = \{1, 2, 3\}. Let 2U2^U denote the powerset of UU. Consider an undirected graph GG whose vertex set is 2U2^U. For any A,B∈2U,(A,B)A,B \in 2^U, (A,B) is an edge in GG if and only if (i) A≠BA \neq B, and (ii) either A⊆BA \subseteq B or B⊆AB \subseteq A. For any vertex AA in GG, the set of all possible orderings in which the vertices of GG can be visited in a Breadth First Search (BFS) starting from AA is denoted by B(A)B(A).
If ϕ\phi denotes the empty set, then the cardinality of B(ϕ)B(\phi ) is ____.

Q57Memory Management2 marksNAT
Consider the following two-dimensional array D in the C programming language, which is stored in row-major order:

int D[128][128];

Demand paging is used for allocating memory and each physical page frame holds 512 elements of the array D. The Least Recently Used (LRU) page-replacement policy is used by the operating system. A total of 30 physical page frames are allocated to a process which executes the following code snippet:

for (int i = 0; i < 128; i++)
       for (int j = 0; j < 128; j++) 
                   D[j][i] *= 10;

The number of page faults generated during the execution of this code snippet is _____.

Q58Memory Management2 marksNAT
Consider a computer system with 57-bit virtual addressing using multi-level tree-structured page tables with L levels for virtual to physical address translation. The page size is 4 KB (1 KB = 1024 B) and a page table entry at any of the levels occupies 8 bytes.
The value of L is ______.

Q59Queue2 marksNAT
Consider a sequence aa of elements a0=1,a1=5,a2=7,a3=8,a4=9,  and  a5=2a_0 = 1, a_1 = 5, a_2 = 7, a_3 = 8, a_4 = 9, \; and \; a_5 = 2. The following operations are performed on a stack SS and a queue QQ, both of which are initially empty.

I: push the elements of a from a0a_0 to a5a_5 in that order into SS.
II: enqueue the elements of a from a0a_0 to a5a_5 in that order into QQ.
III: pop an element from SS.
IV: dequeue an element from QQ.
V: pop an element from SS.
VI: dequeue an element from QQ.
VII: dequeue an element from QQ and push the same element into SS.
VIII: Repeat operation VII three times.
IX: pop an element from SS.
X: pop an element from SS.

The top element of SS after executing the above operations is ___.

Q60Syntax-directed Translation2 marksNAT
Consider the syntax directed translation given by the following grammar and semantic rules. Here N,I,F  and  BN, I, F \; and \; B are non-terminals. NN is the starting non-terminal, and #,0  and  1\#,0 \; and \; 1 are lexical tokens corresponding to input letters "#","0"  and  "1""\#","0" \; and \; "1", respectively. X.valX.val denotes the synthesized attribute (a numeric value) associated with a non-terminal XX. I1I_1 and F1F_1 denote occurrences of II and FF on the right hand side of a production, respectively. For the tokens 00 and 11, 0.val=00.val=0 and 1.val=11.val=1.

The value computed by the translation scheme for the input string
N→I#FN.val=I.val+F.valI→I1BI.val=(2I1.val)+B.valI→BI.val=B.valF→BF1F.val=12(B.val+F1.val)F→BF.val=12B.valB→0B.val=0.valB→1B.val=1.val\begin{aligned} N & \rightarrow I \# F & N.val=I.val+F.val \\ I &\rightarrow I_1B & I.val = (2 I1.val) + B.val\\ I &\rightarrow B&I.val = B.val\\ F &\rightarrow BF_1& F.val = \frac{1}{2}(B.val + F1.val)\\ F &\rightarrow B& F.val = \frac{1}{2} B.val\\ B&\rightarrow 0& B.val = 0.val\\ B &\rightarrow 1&B.val = 1.val \end{aligned}
10#01110\# 011

is ____ (Rounded off to three decimal places)