GATE Computer Science and Information Technology (GATE CS) · GATE
Databases, Theory of Computation, and Compiler Design
17 practice questions covering 24% of the official GATE Computer Science and Information Technology (GATE CS) blueprint. Every item includes a worked explanation of the correct answer.
View all 4 domains in GATE Computer Science and Information Technology (GATE CS)
Syllabus Coverage & Domain Overview
This topic bundles three subjects that together carry roughly a quarter of the paper: databases, the theory of computation, and compiler design. All three reward exact definitions and mechanical procedures more than long derivations, so they suit steady practice.
In databases, the official outline covers the entity-relationship model, the relational model with relational algebra and tuple calculus, SQL, integrity constraints, normal forms, file organisation and indexing with B and B+ trees, and transactions with concurrency control. The central skills are computing attribute closures from a set of functional dependencies, finding every candidate key, and deciding the highest normal form a schema satisfies. You also need to judge whether a decomposition is lossless and whether it preserves dependencies. Third normal form can always be reached with both properties, while Boyce-Codd normal form may cost you dependency preservation. For transactions, you test conflict serializability by drawing a precedence graph and looking for a cycle. For indexing, you work out how many pointers and keys fit in a block.
Theory of computation covers regular expressions and finite automata, context-free grammars and pushdown automata, regular and context-free languages, the pumping lemma, and Turing machines with undecidability. The key distinctions are between the language classes and which operations each class is closed under. Deterministic and nondeterministic machines differ in power for pushdown automata but not for finite automata. Recursive and recursively enumerable languages differ in what a machine does on strings outside the language. For minimal automata, equivalence classes of strings tell you the state count. Many undecidability questions come down to recognising a known undecidable problem, or applying a property that covers all non-trivial languages.
Compiler design covers lexical analysis, parsing, syntax-directed translation, runtime environments and intermediate code generation. Recent syllabi also list local optimisation and data-flow analyses such as constant propagation, liveness analysis and common subexpression elimination. Expect to build FIRST and FOLLOW sets and parsing tables, and to compare parser families. LL(1) grammars sit within the grammars an LR parser can handle, and the bottom-up family runs from LR(0) up through SLR(1) and LALR(1) to canonical LR(1). Syntax-directed questions ask you to evaluate attributes on a parse tree or to count the instructions in a piece of generated code.
Questions are usually framed as a small concrete instance followed by a precise property to compute or judge. Many are multiple-select, where one wrong option ruins the answer, and some need a numerical answer. Common traps include missing a candidate key, treating a lossless decomposition as dependency preserving, assuming a language is regular because a grammar looks simple, and misapplying closure rules. Another trap is forgetting that a conflict-free schedule must also be checked for cycles across all transaction pairs.
To prepare, work through each procedure by hand until it is routine: closures and keys, normalisation checks, precedence graphs, automata minimisation, and parsing tables. Then practise past questions in each area and write down why each wrong option fails. Revisit the closure and hierarchy facts regularly, since they are quick to forget and are tested directly.
In the official GATE Computer Science and Information Technology (GATE CS) examination blueprint, Databases, Theory of Computation, and Compiler Design carries a weightage of 24%. Out of the total examination duration of 3 hr, candidates should budget approximately 43 min for questions from this domain to maintain pace across the paper.
How to Master Databases, Theory of Computation, and Compiler Design for GATE Computer Science and Information Technology (GATE CS)
Our 17 published questions in Databases, Theory of Computation, and Compiler Design are written for PrepIQ Hub and checked as set out in our editorial policy. Each item is written to the hard difficulty level of the GATE exam:
- Targeted Topic Drills: Launch Topic Practice mode to work exclusively through Databases, Theory of Computation, and Compiler Design items and review the step-by-step derivation after each submission.
- Negative Marking Discipline: The GATE Computer Science and Information Technology (GATE CS) deducts ⅓ of the question's marks for each incorrect response. Use the worked explanations in this topic drill to spot common conceptual traps before sitting a timed mock.
- Benchmark Target: Aim for at least 35% accuracy in Databases, Theory of Computation, and Compiler Design drills before moving to full-paper simulations.
Databases, Theory of Computation, and Compiler Design worked examples
Databases, Theory of Computation, and Compiler Design questions from the GATE Computer Science and Information Technology (GATE CS) syllabus, answered in full. Try each one before opening the explanation.
Example 1 · Databases, Theory of Computation, and Compiler Design · hard
Which two statements regarding formal language classes and bottom-up LR parsers are always true? (Select two.)
Show answer and explanation
Correct answers: B. Regular languages are closed under union, intersection, and complement; C. LALR(1) has the same state count as SLR(1) and sits between SLR(1) and CLR(1)
Why
Regular languages are closed under complement, intersection, union, concatenation, and Kleene star ( whereas Context-Free Languages are NOT closed under intersection or complement). In parser power, LR(A) ⊂ SLR(B) ⊂ LALR(B) ⊂ CLR(B), and LALR(B) has the same number of states as LR(A)/SLR(B) by merging CLR(B) states with identical LR(A) cores.
- A. Context-free languages are closed under intersection and set complement — Context-free languages are closed under union, concatenation, and Kleene star, but NOT intersection or complement.
- D. LL(1) grammars strictly contain ambiguous context-free grammars — No ambiguous grammar can be LL(B) or LR(k).
Example 2 · Databases, Theory of Computation, and Compiler Design · hard
Consider a relation schema R(A, B, C, D, E) with the functional dependency set F = {AB -> C, C -> D, D -> B, D -> E}. Which two attribute sets are candidate keys of relation R? (Select two.)
Show answer and explanation
Correct answers: A. Candidate key AB because (AB)+ = {A, B, C, D, E} and A+ or B+ alone is smaller; C. Candidate key AC because C -> D -> B and D -> E give (AC)+ = {A, B, C, D, E}
Why
Attributes A never appear on the right-hand side of any FD, so A must be in every candidate key. A+ = {A}. Test AB: (AB)+ = {A, B, C, D, E} = R, so AB is a candidate key. Since C -> D -> B and D -> B, test AC: (AC)+ = {A, C, D, B, E} = R, and test AD: (AD)+ = {A, D, B, E, C} = R. Thus AB, AC, and AD are minimal superkeys (candidate keys).
- B. Candidate key BCD because B, C, and D appear in the functional dependencies — Attribute A never appears on the right-hand side of any FD, so (BCD)+ = {B, C, D, E}, missing A.
- D. Candidate key DE because D determines both B and E directly in dependency set F — (DE)+ = {D, B, E} which misses both A and C, so DE is not a superkey.
Example 3 · Databases, Theory of Computation, and Compiler Design · hard
Consider two concurrent transactions T1 and T2 in schedule S: R1(X), W2(X), W1(Y), R2(Y). Which two statements about the conflict precedence (serialization) graph of schedule S are true? (Select two.)
Show answer and explanation
Correct answers: A. Both conflicting pairs on X and Y induce the directed edge T1 -> T2; C. The schedule is conflict-serializable and equivalent to T1 followed by T2
Why
For data item X: R1(X) precedes W2(X), creating a conflict edge T1 -> T2. For data item Y: W1(Y) precedes R2(Y), also creating the edge T1 -> T2. There is no edge T2 -> T1, so the precedence graph is acyclic and S is conflict-serializable (equivalent to the serial order T1 followed by T2).
- B. The schedule contains a cycle T1 -> T2 -> T1 and is not conflict-serializable — Both conflicts (R1(X) before W2(X) and W1(Y) before R2(Y)) have T1 before T2, so there is no T2 -> T1 edge.
- D. The schedule is conflict-equivalent to the serial order T2 followed by T1 — In T2 then T1, W2(X) would precede R1(X), reversing the read-write order on X.
Example 4 · Databases, Theory of Computation, and Compiler Design · medium
Consider a relation R(A, B, C) with functional dependencies F = {AB -> C, C -> B}. What is the highest normal form satisfied by relation R?
Show answer and explanation
Correct answer: A. 3NF but not BCNF because C is not a superkey while B is a prime attribute
Why
The candidate keys of R are AB and AC (since (AB)+ = ABC and (AC)+ = ABC). Prime attributes are {A, B, C}. In C -> B, the determinant C is not a superkey, so R violates BCNF. However, the RHS attribute B is a prime attribute (part of candidate key AB), so C -> B does not violate 3NF. Thus R is in 3NF but not BCNF.
- B. BCNF because both AB and C are superkeys of relation R(A, B, C) — C+ = {B, C} does not include A, so C is not a superkey and C -> B violates BCNF.
- C. 1NF because non-prime attributes depend partially on candidate key AB — All three attributes A, B, and C are prime attributes (belonging to AB or AC), so there are no non-prime attributes.
- D. 2NF but not 3NF because B is a non-prime attribute transitively dependent on AB — B is part of the candidate key AB, making B a prime attribute.
Every worked example on this page passed our independent verification before publication — how that works is set out in our editorial policy. Spotted an error? Tell us through the contact page and we will correct it.
All 4 Databases, Theory of Computation, and Compiler Design questions with answers
- Which two statements regarding formal language classes and bottom-up LR parsers are always true? (Select two.)
- Consider a relation schema R(A, B, C, D, E) with the functional dependency set F = {AB -> C, C -> D, D -> B, D -> E}…
- Consider two concurrent transactions T1 and T2 in schedule S: R1(X), W2(X), W1(Y), R2(Y). Which two statements about…
- Consider a relation R(A, B, C) with functional dependencies F = {AB -> C, C -> B}. What is the highest normal form…
All Syllabus Domains in GATE Computer Science and Information Technology (GATE CS)
Programming, Data Structures, and Algorithms
16 questions · 28%Operating Systems and Computer Networks
14 questions · 26%Databases, Theory of Computation, and Compiler Design (Current domain)
17 questions · 24%Digital Logic, Computer Organization, and Discrete Mathematics
16 questions · 22%
GATE is a mark of the Indian Institute of Science and the Indian Institutes of Technology. PrepIQ Hub is not affiliated with, endorsed by, or sponsored by the GATE Committee.