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

GATE 2022

65 questions

MCQ 32 · MSQ 15 · NAT 181-mark 30 · 2-mark 35

Questions 61–65 of 65

Q61Pipeline Processor2 marksNAT
A processor X1X_1 operating at 2 GHz has a standard 5-stage RISC instruction pipeline having a base CPI (cycles per instruction) of one without any pipeline hazards. For a given program P that has 30% branch instructions, control hazards incur 2 cycles stall for every branch. A new version of the processor X2X_2 operating at same clock frequency has an additional branch predictor unit (BPU) that completely eliminates stalls for correctly predicted branches. There is neither any savings nor any additional stalls for wrong predictions. There are no structural hazards and data hazards for X1X_1 and X2X_2. If the BPU has a prediction accuracy of 80%, the speed up (rounded off to two decimal places) obtained by X2X_2 over X1X_1 in executing P is

Q62Queue2 marksNAT
Consider the queues Q1 containing four elements and Q2 containing none (shown as the Initial State in the figure). The only operations allowed on these two queues are Enqueue(Q,element)Enqueue(Q,element) and Dequeue(Q)Dequeue(Q). The minimum number of EnqueueEnqueue operations on Q1 required to place the elements of Q1 in Q2 in reverse order (shown as the Final State in the figure) without using any additional storage is
Initial State Final State Head Head Q1 Q2 Q1 Q2 Head Head 1234 4321

Q63File Systems2 marksNAT
Consider two files systems A and B , that use contiguous allocation and linked allocation, respectively. A file of size 100 blocks is already stored in A and also in B. Now, consider inserting a new block in the middle of the file (between 50th and 51st50^{th} \text{ and }51^{st} block), whose data is already available in the memory. Assume that there are enough free blocks at the end of the file and that the file control blocks are already in memory. Let the number of disk accesses required to insert a block in the middle of the file in A and B are nAn_A and nBn_B, respectively, then the value of nA+nBn_A+n_B is

Q64Memory Management2 marksNAT
Consider a demand paging system with four page frames (initially empty) and LRU page replacement policy. For the following page reference string

7, 2, 7, 3, 2, 5, 3, 4, 6, 7, 7,1, 5, 6,1

the page fault rate, defined as the ratio of number of page faults to the number of memory accesses (rounded off to one decimal place) is

Q65Parsing2 marksNAT
Consider the following grammar along with translation rules.
S→S1#T{S.val=S1.val∗T.val}S→T{S.val=T.val}T→T1%R{T.val=T1.val÷R.val}T→R{T.val=R.val}R→id{R.val=id.val}\begin{aligned} &S \rightarrow S_1 \# T & & \{S._{val}=S_{1.val}*T._{val} \} \\ &S \rightarrow T & & \{S._{val}=T._{val} \} \\ &T \rightarrow T_1 \% R & & \{T._{val}=T_{1.val} \div R._{val} \} \\ &T \rightarrow R & & \{T._{val}=R._{val} \} \\ &R \rightarrow id & & \{R._{val}=id._{val} \} \\ \end{aligned}
Here #\# and %\% are operators and idid is a token that represents an integer and id.valid_{.val} represents the corresponding integer value. The set of non-terminals is {S,T,R,P}\{S,T,R,P \} and a subscripted non-terminal indicates an instance of the non-terminal.
Using this translation scheme, the computed value of S.valS_{.val} for root of the parse tree for the expression 20#10%5#8%2%220 \# 10 \% 5 \# 8 \% 2 \% 2 is