GATE 2026 (Session 1)
65 questions
MCQ 28 · MSQ 24 · NAT 131-mark 30 · 2-mark 35
Questions 51–55 of 65
Let and be two languages over a finite alphabet, such that and are regular languages.
Which of the following statements is/are always true?
Which of the following statements is/are always true?
One or more options are correct.
Answer: (C)
Take (regular) and (not even context-free). Then is regular and is regular, so the given conditions hold.
(A) is not regular here. Not always true.
(B) is not regular here. Not always true.
(D) is not context-free here. Not always true.
(C) is regular, and regular languages are closed under complement, so is regular. Every regular language is context-free, so is context-free. Always true.
Answer: (C)
(A) is not regular here. Not always true.
(B) is not regular here. Not always true.
(D) is not context-free here. Not always true.
(C) is regular, and regular languages are closed under complement, so is regular. Every regular language is context-free, so is context-free. Always true.
Answer: (C)
Consider the following context-free grammar .
In the above grammar, is the start symbol, and are terminal symbols, and and are non-terminal symbols.
Let be the language generated by the grammar . For a string , let be the number of 's in and be the number of 's in .
Which of the following statements is/are true?
In the above grammar, is the start symbol, and are terminal symbols, and and are non-terminal symbols.
Let be the language generated by the grammar . For a string , let be the number of 's in and be the number of 's in .
Which of the following statements is/are true?
One or more options are correct.
Answer: (B), (D)
Count the 's and 's in each part. Let the excess be .
B: gives with . So excess 0, and at least one .
A: each use of an -rule adds terminals plus -parts (excess 0):
- : terminals give 2 a's and 1 b, so excess . It has at least 1 b of its own and at least 2 more from the two 's, so at least 3 b's.
- : terminals give 3 a's and 2 b's, so excess , and at least b's.
An -string uses rules (the last one must be ). So and .
S: has 3 a's and 3 b's in its terminals (excess 0), one (excess 0, at least 1 b) and two -strings with . So , and .
So always. This makes (B) true and (A) false. Also . This makes (D) true and (C) false.
Answer: (B), (D)
B: gives with . So excess 0, and at least one .
A: each use of an -rule adds terminals plus -parts (excess 0):
- : terminals give 2 a's and 1 b, so excess . It has at least 1 b of its own and at least 2 more from the two 's, so at least 3 b's.
- : terminals give 3 a's and 2 b's, so excess , and at least b's.
An -string uses rules (the last one must be ). So and .
S: has 3 a's and 3 b's in its terminals (excess 0), one (excess 0, at least 1 b) and two -strings with . So , and .
So always. This makes (B) true and (A) false. Also . This makes (D) true and (C) false.
Answer: (B), (D)
Consider the following two syntax-directed definitions and for type declarations.
is the start symbol, and int, float and id are the three terminals. The non-terminal is the same as and the non-terminal is the same as . Here, the subscript is used to differentiate the grammar symbols on the two sides of a production. The function put updates the symbol table with the type information for an identifier.
Let and be the languages specified by grammars and , respectively. Which of the following statements is/are true?
is the start symbol, and int, float and id are the three terminals. The non-terminal is the same as and the non-terminal is the same as . Here, the subscript is used to differentiate the grammar symbols on the two sides of a production. The function put updates the symbol table with the type information for an identifier.
Let and be the languages specified by grammars and , respectively. Which of the following statements is/are true?
One or more options are correct.
Answer: (A), (B), (D)
Language equivalence: generates a type keyword followed by one-or-more identifiers (via the recursive ); generates the same thing via a left-recursive . Both accept exactly "type-keyword followed by identifiers," so . True.
SDD2's attribute style: In SDD2, and the actions are all computed purely from the values of the symbols on the right-hand side of each production (children of the node in the parse tree) — every attribute is synthesized, making SDD2 S-attributed. True.
SDD1's attribute style: In SDD1, is set from (an inherited value flowing top-down from the parent into , then further down into ), so SDD1 does use inherited attributes — but itself is synthesized from as well, so SDD1 is L-attributed but it is not true that it contains "only" inherited attributes (it has both kinds). False as stated.
Symbol table contents: In SDD1, is called for every identifier with the type inherited down from . In SDD2, is similarly called for every identifier with the same type value (synthesized bottom-up instead, but numerically identical since there's only one /type per declaration). Since both add exactly one entry per identifier with the same type value, the symbol tables end up identical. True.
Answer: P and Q are the same language; SDD2 is S-attributed with only synthesized attributes; and both SDDs populate the symbol table with the same entries.
SDD2's attribute style: In SDD2, and the actions are all computed purely from the values of the symbols on the right-hand side of each production (children of the node in the parse tree) — every attribute is synthesized, making SDD2 S-attributed. True.
SDD1's attribute style: In SDD1, is set from (an inherited value flowing top-down from the parent into , then further down into ), so SDD1 does use inherited attributes — but itself is synthesized from as well, so SDD1 is L-attributed but it is not true that it contains "only" inherited attributes (it has both kinds). False as stated.
Symbol table contents: In SDD1, is called for every identifier with the type inherited down from . In SDD2, is similarly called for every identifier with the same type value (synthesized bottom-up instead, but numerically identical since there's only one /type per declaration). Since both add exactly one entry per identifier with the same type value, the symbol tables end up identical. True.
Answer: P and Q are the same language; SDD2 is S-attributed with only synthesized attributes; and both SDDs populate the symbol table with the same entries.
Consider a system that has a cache memory unit and a memory management unit (MMU). The address input to the cache memory is a physical address. The MMU has a translation lookaside buffer (TLB). Assume that when a page is evicted from the main memory, the corresponding blocks in the cache are marked as invalid.
For a given memory reference, which of the following sequences of events can NEVER happen?
For a given memory reference, which of the following sequences of events can NEVER happen?
One or more options are correct.
Answer: (B), (C)
A memory reference goes through these steps in order: first the TLB, then the page table (only when the TLB misses), and then the cache.
- TLB miss, Page table hit, Cache hit: This is possible. The TLB does not hold the mapping, but the page table does, so the page is in memory. The cache block for that page can still be valid, so a cache hit can occur. Can happen.
- TLB hit, Page table miss, Cache hit: Impossible. A TLB hit means the page is mapped and present in memory, because TLB entries are valid only for pages that are in memory. So the page table cannot report a miss (page not in memory) for that same page.
- TLB miss, Page table miss, Cache hit: Impossible. A page table miss means the page is not in main memory at all. The problem says that when a page is evicted, its cache blocks are marked invalid. So if the page is not in memory, its cache blocks cannot be valid, and a cache hit cannot happen.
- TLB miss, Page table miss, Cache miss: This is possible. It is the expected sequence when the page is really not in memory.
Answer: "TLB hit, Page table miss, Cache hit" and "TLB miss, Page table miss, Cache hit" can NEVER happen.
- TLB miss, Page table hit, Cache hit: This is possible. The TLB does not hold the mapping, but the page table does, so the page is in memory. The cache block for that page can still be valid, so a cache hit can occur. Can happen.
- TLB hit, Page table miss, Cache hit: Impossible. A TLB hit means the page is mapped and present in memory, because TLB entries are valid only for pages that are in memory. So the page table cannot report a miss (page not in memory) for that same page.
- TLB miss, Page table miss, Cache hit: Impossible. A page table miss means the page is not in main memory at all. The problem says that when a page is evicted, its cache blocks are marked invalid. So if the page is not in memory, its cache blocks cannot be valid, and a cache hit cannot happen.
- TLB miss, Page table miss, Cache miss: This is possible. It is the expected sequence when the page is really not in memory.
Answer: "TLB hit, Page table miss, Cache hit" and "TLB miss, Page table miss, Cache hit" can NEVER happen.
An undirected, unweighted, simple graph is said to be -colorable if there exists a function such that for every .
Which of the following statements about -colorable graphs is/are true?
Which of the following statements about -colorable graphs is/are true?
One or more options are correct.
Answer: (B), (C)
A graph is -colorable only when it is bipartite. This is the same as having no odd-length cycle.
- "May contain cycles of odd length": false. A 2-colorable graph can never have an odd cycle, since that is exactly the bipartite condition.
- "May contain cycles of even length": true. Even cycles are fine in a bipartite graph (the two colors alternate around the cycle, which works exactly when the cycle length is even).
- Algorithm complexity: To test bipartiteness or -colorability, run one BFS or DFS. Color each vertex alternately as it is visited and check for conflicts. On an adjacency list this takes time. It is optimal, because you must look at every vertex and edge at least once. True.
- is not the optimal or usual time for this simple traversal check (that bound fits priority-queue algorithms for MST or shortest path better). So this claim is false for the optimal 2-colorability test.
Answer: G may contain even-length cycles; and the optimal 2-colorability test runs in Θ(|V|+|E|) time.
- "May contain cycles of odd length": false. A 2-colorable graph can never have an odd cycle, since that is exactly the bipartite condition.
- "May contain cycles of even length": true. Even cycles are fine in a bipartite graph (the two colors alternate around the cycle, which works exactly when the cycle length is even).
- Algorithm complexity: To test bipartiteness or -colorability, run one BFS or DFS. Color each vertex alternately as it is visited and check for conflicts. On an adjacency list this takes time. It is optimal, because you must look at every vertex and edge at least once. True.
- is not the optimal or usual time for this simple traversal check (that bound fits priority-queue algorithms for MST or shortest path better). So this claim is false for the optimal 2-colorability test.
Answer: G may contain even-length cycles; and the optimal 2-colorability test runs in Θ(|V|+|E|) time.