GATE 2022
65 questions
MCQ 32 · MSQ 15 · NAT 181-mark 30 · 2-mark 35
Questions 26–30 of 65
Which of the following statements is/are TRUE with respect to deadlocks?
One or more options are correct.
Answer: (A), (D)
(A) TRUE. Circular wait is one of the four necessary conditions for deadlock. The others are mutual exclusion, hold and wait, and no preemption.
(B) FALSE. When resources have many instances, a cycle in the graph is necessary for deadlock but not enough. Another process outside the cycle may release an instance and break the wait.
(C) FALSE. An unsafe state may lead to deadlock, but not always. Processes may give back their resources early.
(D) TRUE. If every edge is an assignment edge, there is no request edge, so no process is waiting for anything. With no waiting, there is no deadlock.
Answer: (A), (D)
(B) FALSE. When resources have many instances, a cycle in the graph is necessary for deadlock but not enough. Another process outside the cycle may release an instance and break the wait.
(C) FALSE. An unsafe state may lead to deadlock, but not always. Processes may give back their resources early.
(D) TRUE. If every edge is an assignment edge, there is no request edge, so no process is waiting for anything. With no waiting, there is no deadlock.
Answer: (A), (D)
Which of the following statements is/are TRUE for a group ?
One or more options are correct.
Answer: (A), (B), (C)
(A) gives . Cancel on the left and on the right: . TRUE.
(B) means every element is its own inverse. Then . TRUE.
(C) A group of order 2 is . It is cyclic, so it is commutative. TRUE.
(D) A subgroup uses the same operation as , so two of its elements commute whenever they do in . A subgroup of a commutative group is always commutative, so the statement is FALSE.
Answer: (A), (B), (C)
(B) means every element is its own inverse. Then . TRUE.
(C) A group of order 2 is . It is cyclic, so it is commutative. TRUE.
(D) A subgroup uses the same operation as , so two of its elements commute whenever they do in . A subgroup of a commutative group is always commutative, so the statement is FALSE.
Answer: (A), (B), (C)
Suppose a binary search tree with 1000 distinct elements is also a complete binary tree. The tree is stored using the array representation of binary heap trees. Assuming that the array indices start with 0, the 3rd largest element of the tree is stored at index _______.
Answer: 509
The tree is complete and has 1000 nodes, so the indices run from 0 to 999. The children of node i are at and .
- Largest: keep going right as far as possible. The path is 0 2 6 14 30 62 126 254 510. The children 1021 and 1022 do not exist, so index 510 holds the largest element.
- 2nd largest: this is the predecessor of 510. Node 510 has no left child, so its predecessor is its parent, which is index 254.
- 3rd largest: this is the maximum of the left subtree of 254. The left child is 509, and its children 1019 and 1020 do not exist, so the maximum is at 509.
Answer: 509
- Largest: keep going right as far as possible. The path is 0 2 6 14 30 62 126 254 510. The children 1021 and 1022 do not exist, so index 510 holds the largest element.
- 2nd largest: this is the predecessor of 510. Node 510 has no left child, so its predecessor is its parent, which is index 254.
- 3rd largest: this is the maximum of the left subtree of 254. The left child is 509, and its children 1019 and 1020 do not exist, so the maximum is at 509.
Answer: 509
Consider the augmented grammar with as the set of terminals.
If is the set of two items , then contains exactly ______ items.
If is the set of two items , then contains exactly ______ items.
Answer: 5
Closure of adds no items (the dot is before + or at the end, never before a non-terminal).
goto on +: . Closure (dot before R, then P):
1.
2.
3.
4.
5.
Answer: 5
goto on +: . Closure (dot before R, then P):
1.
2.
3.
4.
5.
Answer: 5
Consider a simple undirected graph of 10 vertices. If the graph is disconnected, then the maximum number of edges it can have is .
Answer: 36
Split the 10 vertices into two groups of sizes and with no edge between them (a disconnected graph has at least two such groups). Each group can be complete, so the most edges is .
- :
- :
- :
- :
- :
The values fall as goes from 1 to 5 (and repeat in reverse after that), so the largest is at (or ): plus one isolated vertex. With three or more components, joining two of them into one complete group only adds edges, so two components are enough. In general the maximum is .
Maximum edges .
Answer: 36
- :
- :
- :
- :
- :
The values fall as goes from 1 to 5 (and repeat in reverse after that), so the largest is at (or ): plus one isolated vertex. With three or more components, joining two of them into one complete group only adds edges, so two components are enough. In general the maximum is .
Maximum edges .
Answer: 36