GATE 2026 (Session 2)
65 questions
MCQ 35 · MSQ 11 · NAT 191-mark 30 · 2-mark 35
Questions 46–50 of 65
An index in a DBMS is said to be dense if an index entry appears for every search-key value in the indexed file. Otherwise it is called a sparse index. Consider the following two statements.
: A hash index must be a dense index
: A tree index can be a sparse index
Which one of the following options is correct?
: A hash index must be a dense index
: A tree index can be a sparse index
Which one of the following options is correct?
Answer: (A)
S1 (a hash index must be dense): A hash index finds the bucket straight from the key with a hash function. There is no sorted order, so entries cannot be skipped as in a sparse index. So a hash index needs its own entry, pointing to the data, for every distinct search-key value. True.
S2 (a -tree can be sparse): Take a -tree index built on a search key that also fixes the sorted order of the data file (a primary/clustering index). Then one index entry per data block is enough, pointing to the first record of that block. It does not need one entry per record, because the other records in the block can be reached by scanning in order from there. So a sparse -tree index is fully possible. True.
Answer: Both S1 and S2 are true.
S2 (a -tree can be sparse): Take a -tree index built on a search key that also fixes the sorted order of the data file (a primary/clustering index). Then one index entry per data block is enough, pointing to the first record of that block. It does not need one entry per record, because the other records in the block can be reached by scanning in order from there. So a sparse -tree index is fully possible. True.
Answer: Both S1 and S2 are true.
Consider the following two finite automata and .
Which of the following statements is/are true?
Which of the following statements is/are true?
One or more options are correct.
Answer: (C), (D)
Read each machine from its start state, which is also its only final state. Every cycle back to the start state has length 3.
: the loops are 0-0-0, 0-0-1, 0-1-0 and 1-0-1, so .
: the loops are 0-1-1, 1-1-1, 1-0-0 and 1-1-0, so .
The two sets of length-3 blocks have no block in common, and together they contain all 8 strings of length 3.
(A) False: 000 is in but not in . (B) False for the same reason, since is not a subset of . (C) True: a string in both would be a series of length-3 blocks that are in both sets, and no block is common, so only is in both. (D) True: has every length-3 string, so its star is all strings whose length is a multiple of 3.
Answer: (C), (D)
: the loops are 0-0-0, 0-0-1, 0-1-0 and 1-0-1, so .
: the loops are 0-1-1, 1-1-1, 1-0-0 and 1-1-0, so .
The two sets of length-3 blocks have no block in common, and together they contain all 8 strings of length 3.
(A) False: 000 is in but not in . (B) False for the same reason, since is not a subset of . (C) True: a string in both would be a series of length-3 blocks that are in both sets, and no block is common, so only is in both. (D) True: has every length-3 string, so its star is all strings whose length is a multiple of 3.
Answer: (C), (D)
Let and let .
Which of the following constraints ensure(s) that the language is context-free?
Which of the following constraints ensure(s) that the language is context-free?
One or more options are correct.
Answer: (A), (C), (D)
Each language is with a constraint. Test each one with a stack.
(A) : this means . A PDA keeps a running count: add 1 for each and , subtract 1 for each and . The count can be positive or negative, but it can always be kept on one stack: push while the count is positive, and if the stack is empty when a subtract is needed, push to record a negative count (and then cancel against the next adds). Accept when the stack is empty at the end. So it is context-free.
(B) and : the language is . The 's match the 's and the 's match the 's, and these two matchings cross. One stack cannot do both. (The pumping lemma for CFLs on shows it.) Not context-free.
(C) and : the language is . The matchings are nested: push the 's, push the 's, pop them for the 's, then pop the 's for the 's. Context-free.
(D) : push one symbol for each and , then pop one for each and . Accept when the stack is empty at the end. Context-free.
Answer: (A), (C), (D)
(A) : this means . A PDA keeps a running count: add 1 for each and , subtract 1 for each and . The count can be positive or negative, but it can always be kept on one stack: push while the count is positive, and if the stack is empty when a subtract is needed, push to record a negative count (and then cancel against the next adds). Accept when the stack is empty at the end. So it is context-free.
(B) and : the language is . The 's match the 's and the 's match the 's, and these two matchings cross. One stack cannot do both. (The pumping lemma for CFLs on shows it.) Not context-free.
(C) and : the language is . The matchings are nested: push the 's, push the 's, pop them for the 's, then pop the 's for the 's. Context-free.
(D) : push one symbol for each and , then pop one for each and . Accept when the stack is empty at the end. Context-free.
Answer: (A), (C), (D)
Consider a binary search tree (BST) with leaf nodes . Given any node , the key present in the node is denoted as . All the keys present in the given BST are distinct. The keys belong to the set of real numbers.
For a node , let denote the node that is its inorder successor. If a node does not have an inorder successor, then is . As there are no duplicates, if is not , then .
Corresponding to every leaf node that has a non-NULL , a new key with the following property is to be inserted into the BST.
Let represent the list of all such new keys to be inserted into the BST.
Which of the following statements is/are true?
For a node , let denote the node that is its inorder successor. If a node does not have an inorder successor, then is . As there are no duplicates, if is not , then .
Corresponding to every leaf node that has a non-NULL , a new key with the following property is to be inserted into the BST.
Let represent the list of all such new keys to be inserted into the BST.
Which of the following statements is/are true?
One or more options are correct.
Answer: (A), (C)
(A) True. Each new key lies strictly between two keys that are neighbours in the in-order sequence: a leaf and its successor. Different leaves give different neighbour pairs, so these intervals do not overlap and no two new keys can be equal.
(B) False. In a tree with one node, that node is the only leaf and has no in-order successor. No key is added and is empty.
(C) True. Take with . No key lies between these two, so is compared with every other key just as is. So the search reaches , and because it goes right. A leaf has no right child, so becomes the right child of . Each leaf gets at most one new child, so every path grows by at most 1 and the height rises by at most 1.
(D) False. At most one node is added per leaf, so at most new nodes. A tree with more than one node also has internal nodes, so its node count is more than . Then at most new nodes cannot double it. A single node tree gets no new node.
Answer: (A), (C)
(B) False. In a tree with one node, that node is the only leaf and has no in-order successor. No key is added and is empty.
(C) True. Take with . No key lies between these two, so is compared with every other key just as is. So the search reaches , and because it goes right. A leaf has no right child, so becomes the right child of . Each leaf gets at most one new child, so every path grows by at most 1 and the height rises by at most 1.
(D) False. At most one node is added per leaf, so at most new nodes. A tree with more than one node also has internal nodes, so its node count is more than . Then at most new nodes cannot double it. A single node tree gets no new node.
Answer: (A), (C)
Consider a stack and a queue . Both of them are initially empty and have the capacity to store ten elements each. The elements , and arrive one by one, in that order. When an element arrives, it is assigned either to (pushed on ) or to (enqueued to ). Once all the five elements are stored, the output is generated in two steps. First, stack S is emptied by popping all elements. Then queue is emptied by dequeueing all elements. The output obtained by following this process is .
Given the output, the objective is to predict whether an element was assigned to or .
Which of the following options is/are possible valid assignment(s) of the elements?
Note: In the options, the notation denotes that element was assigned to and denotes that element was assigned to .
Given the output, the objective is to predict whether an element was assigned to or .
Which of the following options is/are possible valid assignment(s) of the elements?
Note: In the options, the notation denotes that element was assigned to and denotes that element was assigned to .
One or more options are correct.
Answer: (A), (B)
The output has two parts. The stack elements come out first, in reverse of the order they were pushed. Then the queue elements come out in the same order they were enqueued. The target output is .
For each option, split the elements into an list and a list. For the stack list, take the arrival order and then reverse it for popping. For the queue list, keep the arrival order.
- 1S,2Q,3S,4S,5Q: Stack gets pushed in the order → popped as . Queue gives: . Combined: — matches!
- 1Q,2Q,3S,4S,5Q: Stack gets pushed in the order → popped as . Queue gives: . Combined: — matches!
- 1Q,2Q,3Q,4S,5S: Stack gets pushed in the order → popped as . Queue gives: . Combined: — does not match.
- 1S,2S,3S,4Q,5Q: Stack gets pushed in the order → popped as . Queue gives: . Combined: — does not match.
Answer: "1S,2Q,3S,4S,5Q" and "1Q,2Q,3S,4S,5Q" are both valid assignments.
For each option, split the elements into an list and a list. For the stack list, take the arrival order and then reverse it for popping. For the queue list, keep the arrival order.
- 1S,2Q,3S,4S,5Q: Stack gets pushed in the order → popped as . Queue gives: . Combined: — matches!
- 1Q,2Q,3S,4S,5Q: Stack gets pushed in the order → popped as . Queue gives: . Combined: — matches!
- 1Q,2Q,3Q,4S,5S: Stack gets pushed in the order → popped as . Queue gives: . Combined: — does not match.
- 1S,2S,3S,4Q,5Q: Stack gets pushed in the order → popped as . Queue gives: . Combined: — does not match.
Answer: "1S,2Q,3S,4S,5Q" and "1Q,2Q,3S,4S,5Q" are both valid assignments.