GATE 2023
65 questions
MCQ 34 · MSQ 15 · NAT 161-mark 30 · 2-mark 35
Questions 56–60 of 65
Let . Let denote the powerset of . Consider an undirected graph whose vertex set is . For any is an edge in if and only if (i) , and (ii) either or . For any vertex in , the set of all possible orderings in which the vertices of can be visited in a Breadth First Search (BFS) starting from is denoted by .
If denotes the empty set, then the cardinality of is ____.
If denotes the empty set, then the cardinality of is ____.
Answer: 5040
is a subset of every set, so is adjacent to all the other vertices.
BFS starting from visits all 7 neighbours at level 1. These 7 can come in any order, so the count is .
Answer: 5040
BFS starting from visits all 7 neighbours at level 1. These 7 can come in any order, so the count is .
Answer: 5040
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:
The number of page faults generated during the execution of this code snippet is _____.
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 _____.
Answer: 4096
One page holds 512 ints. Each row of D has 128 ints, so a page holds 4 rows. D has 128 rows, so it takes pages.
The code reads D[j][i] with j in the inner loop, so it goes down a column. For one value of i, j runs from 0 to 127 and touches all 32 pages in order, 4 consecutive accesses per page. The first access to a page faults and the next 3 hit.
There are only 30 frames and the policy is LRU. The pages are used in the cycle 0, 1, ..., 31, then 0 again. When a page is needed, it was used longer ago than the 30 pages that LRU has kept, so it has already been removed. So the first access to each page in every pass is a fault: 32 faults for each i.
Total faults =
Answer: 4096
The code reads D[j][i] with j in the inner loop, so it goes down a column. For one value of i, j runs from 0 to 127 and touches all 32 pages in order, 4 consecutive accesses per page. The first access to a page faults and the next 3 hit.
There are only 30 frames and the policy is LRU. The pages are used in the cycle 0, 1, ..., 31, then 0 again. When a page is needed, it was used longer ago than the 30 pages that LRU has kept, so it has already been removed. So the first access to each page in every pass is a fault: 32 faults for each i.
Total faults =
Answer: 4096
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 ______.
The value of L is ______.
Answer: 5
The page size is 4 KB so there are 12 offset bits. The VPN has bits.
One page-table page can store entries so every level handles 9 bits.
Number of levels:
Answer: 5
One page-table page can store entries so every level handles 9 bits.
Number of levels:
Answer: 5
Consider a sequence of elements . The following operations are performed on a stack and a queue , both of which are initially empty.
I: push the elements of a from to in that order into .
II: enqueue the elements of a from to in that order into .
III: pop an element from .
IV: dequeue an element from .
V: pop an element from .
VI: dequeue an element from .
VII: dequeue an element from and push the same element into .
VIII: Repeat operation VII three times.
IX: pop an element from .
X: pop an element from .
The top element of after executing the above operations is ___.
I: push the elements of a from to in that order into .
II: enqueue the elements of a from to in that order into .
III: pop an element from .
IV: dequeue an element from .
V: pop an element from .
VI: dequeue an element from .
VII: dequeue an element from and push the same element into .
VIII: Repeat operation VII three times.
IX: pop an element from .
X: pop an element from .
The top element of after executing the above operations is ___.
Answer: 8
After steps I and II: S = [1, 5, 7, 8, 9, 2] (top = 2), Q = [1, 5, 7, 8, 9, 2] (front = 1).
- III: pop S takes out 2
- IV: dequeue Q takes out 1
- V: pop S takes out 9 S = [1, 5, 7, 8]
- VI: dequeue Q takes out 5 Q = [7, 8, 9, 2]
- VII + VIII (4 times): 7, 8, 9, 2 go from Q into S S = [1, 5, 7, 8, 7, 8, 9, 2]
- IX, X: pop 2 and 9 top = 8
Answer: 8
- III: pop S takes out 2
- IV: dequeue Q takes out 1
- V: pop S takes out 9 S = [1, 5, 7, 8]
- VI: dequeue Q takes out 5 Q = [7, 8, 9, 2]
- VII + VIII (4 times): 7, 8, 9, 2 go from Q into S S = [1, 5, 7, 8, 7, 8, 9, 2]
- IX, X: pop 2 and 9 top = 8
Answer: 8
Consider the syntax directed translation given by the following grammar and semantic rules. Here are non-terminals. is the starting non-terminal, and are lexical tokens corresponding to input letters , respectively. denotes the synthesized attribute (a numeric value) associated with a non-terminal . and denote occurrences of and on the right hand side of a production, respectively. For the tokens and , and .
The value computed by the translation scheme for the input string
is ____ (Rounded off to three decimal places)
The value computed by the translation scheme for the input string
is ____ (Rounded off to three decimal places)
Answer: 2.374 to 2.376
Integer part "10" (binary):
I for "1" = 1; I for "10" = .
Fraction part "011" (evaluated right to left):
- F("1") =
- F("11") =
- F("011") =
N.val = 2 + 0.375 = 2.375 (i.e. binary 10.011).
Answer: 2.375
I for "1" = 1; I for "10" = .
Fraction part "011" (evaluated right to left):
- F("1") =
- F("11") =
- F("011") =
N.val = 2 + 0.375 = 2.375 (i.e. binary 10.011).
Answer: 2.375