GATE 2025 (Session 2)
65 questions
MCQ 32 · MSQ 18 · NAT 151-mark 30 · 2-mark 35
Questions 51–55 of 65
Consider two grammars and with the production rules given below:
where are the terminals.
Which of the following option(s) is/are CORRECT?
where are the terminals.
Which of the following option(s) is/are CORRECT?
One or more options are correct.
Answer: (C), (D)
LL(1): in , both and begin with . One token of lookahead cannot choose, so there is a FIRST/FIRST conflict and is not LL(1). In , and both can begin with , because . Again a FIRST/FIRST conflict, so is not LL(1).
Ambiguity of : has two parse trees: the else goes with the inner if or with the outer if.
Ambiguity of : take .
- Tree 1: , where and derives . The outer if has no else.
- Tree 2: , where and . Here the last else belongs to the outer if.
The rule allows an unmatched if after an else, which makes this possible. So is ambiguous too.
So (A) and (B) are false.
Answer: (C), (D)
Ambiguity of : has two parse trees: the else goes with the inner if or with the outer if.
Ambiguity of : take .
- Tree 1: , where and derives . The outer if has no else.
- Tree 2: , where and . Here the last else belongs to the outer if.
The rule allows an unmatched if after an else, which makes this possible. So is ambiguous too.
So (A) and (B) are false.
Answer: (C), (D)
Let . For , and , let denote the number of occurrences of in .
Which one or more of the following option(s) define(s) regular language(s)?
Which one or more of the following option(s) define(s) regular language(s)?
One or more options are correct.
Answer: (A), (C)
(A) is the language of , since the two counts are independent. Regular.
(B) Intersecting with removes every string containing . So must be empty, which forces . What is left is . If is the pumping length, pumping the 's of gives more or fewer 's than 's. Not regular.
(C) Only and matter. A DFA with states can keep both remainders and accept the state . Regular.
(D) Intersect with the regular language . This gives . For a pumping length , take with and . The pumped part lies in the 's, and pumping it down leaves fewer 's than 's, so the string leaves the language. This intersection is not regular, and regular languages are closed under intersection, so (D) is not regular.
Answer: (A), (C)
(B) Intersecting with removes every string containing . So must be empty, which forces . What is left is . If is the pumping length, pumping the 's of gives more or fewer 's than 's. Not regular.
(C) Only and matter. A DFA with states can keep both remainders and accept the state . Regular.
(D) Intersect with the regular language . This gives . For a pumping length , take with and . The pumped part lies in the 's, and pumping it down leaves fewer 's than 's, so the string leaves the language. This intersection is not regular, and regular languages are closed under intersection, so (D) is not regular.
Answer: (A), (C)
Consider the database transactions and , and data items and . Which of the schedule(s) is/are conflict serializable?
One or more options are correct.
Answer: (B)
Draw the conflict (precedence) graph for each schedule. Add an edge when an operation of on a data item comes before a conflicting operation of on the same item. Two operations conflict when they touch the same item and at least one is a write. The schedule is conflict serializable only if the graph has no cycle.
(A) : the first comes before , so . But the later comes after , so . This is a cycle. Not serializable.
(B) : comes before and before , and comes before . Every edge is (the final comes after has committed). There is no cycle. Conflict serializable, equivalent to the serial order .
(C) : comes before , so . But comes before the second , so . Cycle. Not serializable.
(D) : comes before , so . But comes before , so . Cycle. Not serializable.
Answer: (B)
(A) : the first comes before , so . But the later comes after , so . This is a cycle. Not serializable.
(B) : comes before and before , and comes before . Every edge is (the final comes after has committed). There is no cycle. Conflict serializable, equivalent to the serial order .
(C) : comes before , so . But comes before the second , so . Cycle. Not serializable.
(D) : comes before , so . But comes before , so . Cycle. Not serializable.
Answer: (B)
Consider the following relational schema:
Which of the following options is/are correct SQL query/queries to retrieve the names of the students enrolled in course number (i.e. courseno) 1470?
Which of the following options is/are correct SQL query/queries to retrieve the names of the students enrolled in course number (i.e. courseno) 1470?
One or more options are correct.
Answer: (A), (C), (D)
A student qualifies when at least one Enrolled row has the same rollno and courseno 1470.
- (A) is correct. The correlated EXISTS is true exactly when such an Enrolled row exists.
- (B) is not correct. SIZEOF is not an SQL operator, so the query is not valid SQL.
- (C) is correct. COUNT(*) of the matching rows is more than 0 exactly when the same Enrolled row exists, so it gives the same students as EXISTS.
- (D) is correct. Students and Enrolled have only rollno in common, so NATURAL JOIN joins on rollno. The WHERE keeps courseno 1470. Since (rollno, courseno) is the key of Enrolled, each student has at most one such row, so no name is repeated.
Answer: (A), (C), (D)
- (A) is correct. The correlated EXISTS is true exactly when such an Enrolled row exists.
- (B) is not correct. SIZEOF is not an SQL operator, so the query is not valid SQL.
- (C) is correct. COUNT(*) of the matching rows is more than 0 exactly when the same Enrolled row exists, so it gives the same students as EXISTS.
- (D) is correct. Students and Enrolled have only rollno in common, so NATURAL JOIN joins on rollno. The WHERE keeps courseno 1470. Since (rollno, courseno) is the key of Enrolled, each student has at most one such row, so no name is repeated.
Answer: (A), (C), (D)
Given a computing system with two levels of cache (L1 and L2) and a main memory. The first level (L1) cache access time is 1 nanosecond (ns) and the "hit rate" for L1 cache is 90% while the processor is accessing the data from L1 cache. Whereas, for the second level (L2) cache, the "hit rate" is 80% and the "miss penalty" for transferring data from L2 cache to L1 cache is 10 ns. The "miss penalty" for the data to be transferred from main memory to L2 cache is 100 ns.
Then the average memory access time in this system in nanoseconds is ___________ . (rounded off to one decimal place)
Then the average memory access time in this system in nanoseconds is ___________ . (rounded off to one decimal place)
Answer: 4
The L1 access time ( ns) is always spent first, whatever happens next. L2 and main memory are used only after a miss. So the average access time must count three cases: an L1 hit, an L1 miss followed by an L2 hit, and a miss in both followed by main memory:
Here ns is the extra penalty to bring data from L2 to L1 (added to the L1 time already spent). ns is the further extra penalty to bring data from main memory (added to the L1 and L2 time already spent). The hit rates are .
Answer: 4.0
Here ns is the extra penalty to bring data from L2 to L1 (added to the L1 time already spent). ns is the further extra penalty to bring data from main memory (added to the L1 and L2 time already spent). The hit rates are .
Answer: 4.0