GATE 2021 (Session 2)
64 questions
MCQ 33 · MSQ 13 · NAT 181-mark 29 · 2-mark 35
Questions 56–60 of 64
Which of the following regular expressions represent(s) the set of all binary numbers that are divisible by three? Assume that the string is divisible by three.
One or more options are correct.
Answer: (A), (B), (C)
The DFA for "value mod 3" has states 0, 1, 2 (start state and final state is 0). Reading bit takes state to state . So the moves are: state 0 on 0 stays at 0, on 1 goes to 1; state 1 on 0 goes to 2, on 1 goes to 0; state 2 on 0 goes to 1, on 1 stays at 2.
- (A) In state 0, "0" stays. "1" goes to state 1. From state 1, the part loops: "0" goes to state 2, any number of 1s stay at state 2, and "0" goes back to state 1. The last "1" returns to state 0. True
- (B) Same paths, written another way. In state 0: "0" stays, or "11" goes 0 to 1 to 0. Or "10" goes to state 2, then loops at state 2 ("1" stays, "00" goes 2 to 1 to 2), and "01" leaves state 2 and ends at state 0 (2 to 1 to 0). Those are all the ways back to state 0. True
- (C) where is the loop of option (A). So it is the same language as (A). True
- (D) It cannot give 1001 (= 9, divisible by 3), because every part starts with 0 or 11 and 1001 starts with 10. False
Answer: (A), (B), (C)
- (A) In state 0, "0" stays. "1" goes to state 1. From state 1, the part loops: "0" goes to state 2, any number of 1s stay at state 2, and "0" goes back to state 1. The last "1" returns to state 0. True
- (B) Same paths, written another way. In state 0: "0" stays, or "11" goes 0 to 1 to 0. Or "10" goes to state 2, then loops at state 2 ("1" stays, "00" goes 2 to 1 to 2), and "01" leaves state 2 and ends at state 0 (2 to 1 to 0). Those are all the ways back to state 0. True
- (C) where is the loop of option (A). So it is the same language as (A). True
- (D) It cannot give 1001 (= 9, divisible by 3), because every part starts with 0 or 11 and 1001 starts with 10. False
Answer: (A), (B), (C)
Consider a three-level page table to translate a 39-bit virtual address to a physical address as shown below:
The page size is 4 KB = (1KB = bytes) and page table entry size at every level is 8 bytes. A process P is currently using 2 GB (1 GB = bytes) virtual memory which is mapped to 2 GB of physical memory. The minimum amount of memory required for the page table of P across all levels is _________ KB
The page size is 4 KB = (1KB = bytes) and page table entry size at every level is 8 bytes. A process P is currently using 2 GB (1 GB = bytes) virtual memory which is mapped to 2 GB of physical memory. The minimum amount of memory required for the page table of P across all levels is _________ KB
Answer: 4108
Number of pages = 2 GB / 4 KB = pages. One page-table page holds 4096 / 8 = 512 = entries.
To get the minimum, take the pages as contiguous:
- Level 3: pages
- Level 2: 1024 entries 2 pages
- Level 1: 1 page
Total = 1027 pages 4 KB = 4108 KB
Answer: 4108
To get the minimum, take the pages as contiguous:
- Level 3: pages
- Level 2: 1024 entries 2 pages
- Level 1: 1 page
Total = 1027 pages 4 KB = 4108 KB
Answer: 4108
Consider the following ANSI C program
#include <stdio.h>
int foo(int x, int y, int q)
{
if ((x <= 0) && (y <= 0))
return q;
if (x <= 0)
return foo(x, y-q, q);
if (y <= 0)
return foo(x-q, y, q);
return foo(x, y-q, q) + foo(x-q, y, q);
}
int main( )
{
int r = foo(15, 15, 10);
printf("%d", r);
return 0;
} The output of the program upon execution is ____Answer: 60
Let F(x, y) = foo(x, y, 10). Each of the two values goes down from 15 5 5.
- F(5, 5) = 10
- F(5, 5) = F(5, 5) = 10, and in the same way F(5, 5) = 10
- F(5, 5) = F(5, 5) + F(5, 5) = 20
- F(15, 5) = F(5, 5) = 10, so F(15, 5) = F(15, 5) + F(5, 5) = 30
- By symmetry, F(5, 15) = 30
F(15, 15) = F(15, 5) + F(5, 15) = 60
Answer: 60
- F(5, 5) = 10
- F(5, 5) = F(5, 5) = 10, and in the same way F(5, 5) = 10
- F(5, 5) = F(5, 5) + F(5, 5) = 20
- F(15, 5) = F(5, 5) = 10, so F(15, 5) = F(15, 5) + F(5, 5) = 30
- By symmetry, F(5, 15) = 30
F(15, 15) = F(15, 5) + F(5, 15) = 60
Answer: 60
Let S be a set of consisting of 10 elements. The number of tuples of the form (A,B) such that A and B are subsets of S, and is _______
Answer: 59049
Take the condition . Every element of S falls into exactly one of 3 cases: it is not in B, it is in B but not in A, or it is in A.
So the count is:
Answer: 59049
So the count is:
Answer: 59049
Consider the following augmented grammar with as the set of terminals.
Let . The number of items in the set is ___________
Let . The number of items in the set is ___________
Answer: 8
In , the item moves over and becomes . Its closure then brings in all 7 S-items with the dot at the start. So we get 1 + 7 = 8 items.
Now take GOTO on once more, using the item in that set. This gives the same set again, so it has 8 items.
Answer: 8
Now take GOTO on once more, using the item in that set. This gives the same set again, so it has 8 items.
Answer: 8