GATE 2025 Previous Year Questions (PYQs) with Solutions
Real questions from the GATE 2025 paper, solved. Every question below shows its options, the correct answer, and a full text solution — free to read, no login needed. Open any question to practice it interactively inside its course.
- Questions:
- 133
- With solutions:
- 131
- Tagged GATE 2025 in the bank:
- 134
- Q1.GATE 2025
A disk of size 512M bytes is divided into blocks of 64K bytes. A file is stored in the disk using linked allocation. In linked allocation, each data block reserves 4 bytes to store the pointer to the next data block. The link part of the last data block contains a NULL pointer (also of 4 bytes). Suppose a file of 1M bytes needs to be stored in the disk. Assume, 1K = 210 and 1M = 220 . The amount of space in bytes that will be wasted due to internal fragmentation is ______.(Answer in integer)?
Correct answer: 65468
Solution
Disk block size: 64 K bytes = 2^16 = 65,536 bytes
Each block reserves 4 bytes for the pointer to the next block.
Data space available per block = 65,536 − 4 = 65,532 bytes
File size: 1 M = 2^20 = 1,048,576 bytes
Number of blocks required = ceil(1,048,576 / 65,532) = ceil(16.000976...) = 17 blocks
Data stored in 16 full blocks = 16 × 65,532 = 1,048,512 bytes
Remaining data to store in the 17th block = 1,048,576 − 1,048,512 = 64 bytes
Last block data used: 64 bytes
Internal fragmentation (wasted space) in last block = 65,532 − 64 = 65,468 bytes
Answer: 65468 bytes
A video solution is available for this question — log in and enroll to watch it.
- Q2.GATE 2025
Suppose in a multiprogramming environment, the following C program segment is executed. A process goes into I/O queue whenever an I/O related operation is performed. Assume that there will always be a context switch whenever a process requests for an I/O, and also whenever the process returns from an I/O. The number of times the process will enter the ready queue during its lifetime (not counting the time the process enters the ready queue when it is run initially) is _______. (Answer in integer)?
int main() {
int x=0,i=0;
scanf("%d",&x);
for(i=0; i<20; i++)
{ x = x+20;
printf("%d\n",x);
} return 0;
}
Correct answer: 21
Solution
Explanation: Each I/O operation causes the process to request I/O (causing a context switch) and when that I/O completes the process returns and enters the ready queue. We do not count the initial placement of the process on the ready queue when it first starts.
The program performs one input operation using scanf. After the scanf completes the process returns from I/O and enters the ready queue once: +1
The printf statement is executed 20 times inside the loop. Each printf causes an I/O request and later a return to the ready queue, contributing 20 entries: +20
Total: 1 + 20 = 21. Therefore the process enters the ready queue 21 times (not counting the initial run).
A video solution is available for this question — log in and enroll to watch it.
- Q3.GATE 2025
Consider a demand paging system with three frames, and the following page reference string: 1 2 3 4 5 4 1 6 4 5 1 3 2. The contents of the frames are as follows initially and after each reference (from left to right):

The *-marked references cause page replacements.
Which one or more of the following could be the page replacement policy/policies in use?
- A.
Least Recently Used page replacement policy
- B.
Least Frequently Used page replacement policy5
- C.
Most Frequently Used page replacement policy
- D.
Optimal page replacement policy
Correct answer: D
Solution
We have 3 frames and the reference string: 1, 2, 3, 4, 5, 4, 1, 6, 4, 5, 1, 3, 2.
Analyze the starred replacements by comparing future uses of pages currently in the frames.
After the first three misses we have {1, 2, 3}.
When 4 is referenced (first replacement), the next uses of 1, 2, 3 are at positions 7, 13, and 12 respectively. The page whose next use is farthest away is page 2 (position 13), so evict 2 and load 4 → {1, 3, 4}.
When 5 is referenced next, the frames are {1, 3, 4}. Their next uses are at positions 7 for 1, 12 for 3, and 6 for 4. The farthest is 3 (position 12), so evict 3 and load 5 → {1, 4, 5}.
When 6 is referenced later, the frames are {1, 4, 5}. Their next uses after that point are 1 at position 11, 4 at 9, and 5 at 10. The farthest future use is page 1 (position 11), so evict 1 and load 6 → {6, 4, 5}.
When 1 is referenced again (later miss), the remaining future references are only 3 and 2, so none of 6, 4, 5 are used again. Any of them could be evicted; the table shows 6 replaced resulting in {1, 4, 5}. Subsequent replacements follow the same future-use logic.
These choices match the rule: evict the page whose next use is farthest in the future (or never used again).
Why the other common policies do not match this sequence:
Least Recently Used (LRU): At the replacement for 4, LRU would evict the page that was used least recently (page 1), but the table evicts page 2. This disagreement shows LRU does not produce the shown sequence.
Least Frequently Used (LFU) and Most Frequently Used (MFU): These use past access counts, not future knowledge. For example, just before loading 6 the frames are {1, 4, 5} with counts 1:2, 4:2, 5:1, so LFU would evict page 5 (lowest count), but the table evicts page 1. Relying on past frequencies cannot explain the consistent future-driven evictions in the table.
Answer: Optimal page replacement policy
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q4.GATE 2025
Processes 𝑃1, 𝑃2, 𝑃3, 𝑃4 arrive in that order at times 0, 1, 2, and 8 milliseconds respectively, and have execution times of 10, 13, 6, and 9 milliseconds respectively. Shortest Remaining Time First (SRTF) algorithm is used as the CPU scheduling policy. Ignore context switching times.
Which ONE of the following correctly gives the average turnaround time of the four processes in milliseconds?
- A.
22
- B.
15
- C.
37
- D.
19
Correct answer: D
Solution
Turnaround Time (TAT) Calculation
Key idea: With Shortest Remaining Time First (SRTF), the CPU always runs the process with the smallest remaining burst; processes can be preempted when a shorter job arrives.
Scheduling timeline (by time intervals):
0–2 ms: Process P1 starts at 0; it runs until P3 arrives at 2 (P1 has 8 ms remaining at time 2).
2–8 ms: Process P3 (burst 6) has the shortest remaining time and runs to completion at 8 ms.
8–16 ms: At time 8 ms P4 arrives. Among remaining processes, P1 has 8 ms, P4 has 9 ms, P2 has 13 ms; P1 is shortest and runs from 8 to 16 ms, finishing at 16 ms.
16–25 ms: Next shortest is P4 (9 ms); it runs from 16 to 25 ms and finishes at 25 ms.
25–38 ms: Finally P2 runs for its remaining 13 ms and finishes at 38 ms.
Completion times and turnaround times:
P1: arrival 0 ms, completion 16 ms ⇒ turnaround = 16 − 0 = 16 ms
P2: arrival 1 ms, completion 38 ms ⇒ turnaround = 38 − 1 = 37 ms
P3: arrival 2 ms, completion 8 ms ⇒ turnaround = 8 − 2 = 6 ms
P4: arrival 8 ms, completion 25 ms ⇒ turnaround = 25 − 8 = 17 ms
Average turnaround time:
Average TAT = (16 + 37 + 6 + 17) / 4 = 76 / 4 = 19 ms
Therefore the average turnaround time of the four processes is 19 milliseconds.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q5.GATE 2025
A computer has two processors, 𝑀1 and 𝑀2. Four processes 𝑃1, 𝑃2, 𝑃3, 𝑃4 with CPU bursts of 20, 16, 25, and 10 milliseconds, respectively, arrive at the same time and these are the only processes in the system. The scheduler uses non-preemptive priority scheduling, with priorities decided as follows:
• 𝑀1 uses priority of execution for the processes as, 𝑃1 > 𝑃3 > 𝑃2 > 𝑃4, i.e., 𝑃1 and 𝑃4 have highest and lowest priorities, respectively.
• 𝑀2 uses priority of execution for the processes as, 𝑃2 > 𝑃3 > 𝑃4 > 𝑃1, i.e., 𝑃2 and 𝑃1 have highest and lowest priorities, respectively.
A process 𝑃𝑖 is scheduled to a processor 𝑀𝑘, if the processor is free and no other process 𝑃𝑗 is waiting with higher priority. At any given point of time, a process can be allocated to any one of the free processors without violating the execution priority rules. Ignore the context switch time. What will be the average waiting time of the processes in milliseconds
- A.
9.00
- B.
8.75
- C.
6.50
- D.
7.50
Correct answer: A
Solution
Given:
Bursts: P1 = 20 ms, P2 = 16 ms, P3 = 25 ms, P4 = 10 ms (all arrive at time 0)
Two processors, non-preemptive scheduling
Priorities on M1: P1 > P3 > P2 > P4
Priorities on M2: P2 > P3 > P4 > P1
Rule: When a processor becomes free, assign any waiting process provided there is no other waiting process with higher priority for that processor.
Step-by-step scheduling:
t = 0 (both processors free):
M1 runs P1 from 0 to 20 ms (P1 has highest priority on M1).
M2 runs P2 from 0 to 16 ms (P2 has highest priority on M2).
t = 16 ms (M2 becomes free; P1 still on M1):
Waiting processes: P3 and P4. For M2, P3 has higher priority than P4, so M2 runs P3 from 16 to 41 ms.
t = 20 ms (M1 becomes free; P3 running on M2):
Only P4 is waiting, and no higher-priority waiting process exists for M1, so M1 runs P4 from 20 to 30 ms.
Gantt-like view (times in ms):
M1: | P1 (0–20) | P4 (20–30) | idle (30–41)
M2: | P2 (0–16) | P3 (16–41)
Waiting times (start time − arrival time, arrival = 0):
P1: 0 ms
P2: 0 ms
P3: 16 ms
P4: 20 ms
Average waiting time = (0 + 0 + 16 + 20) / 4 = 9 ms
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q6.GATE 2025
In optimal page replacement algorithm, information about all future page references is available to the operating system (OS). A modification of the optimal page replacement algorithm is as follows:
The OS correctly predicts only up to next 4 page references (including the current page) at the time of allocating a frame to a page.
A process accesses the pages in the following order of page numbers:
1, 3, 2, 4, 2, 3, 1, 2, 4, 3, 1, 4.
If the system has three memory frames that are initially empty, the number of page faults that will occur during execution of the process is ________ . (Answer in integer)?
Correct answer: 6
Solution
Improved solution (modified optimal with 4-reference lookahead):
Rule used: When a page must be replaced, the OS correctly predicts only the current and next 3 page references (a 4-reference window). Among pages currently in frames, evict the page whose next use is farthest inside that 4-reference window. If a page is not used within the window, evict that page.
Access page 1. Frames become [1, -, -]. Page fault (total faults = 1).
Access page 3. Frames become [1, 3, -]. Page fault (total = 2).
Access page 2. Frames become [1, 3, 2]. Page fault (total = 3).
Access page 4. Lookahead window (current + next 3): pages [4, 2, 3, 1]. Next uses of pages in frames: 1 at position 7, 3 at position 6, 2 at position 5 (all inside window). Evict the page used farthest in the window (page 1). Frames become [4, 3, 2]. Page fault (total = 4).
Access page 2. Page 2 is already in frames. Hit (total faults = 4).
Access page 3. Page 3 is in frames. Hit (total faults = 4).
Access page 1. Lookahead window: [1, 2, 4, 3]. Next uses of pages in frames [4, 3, 2]: 4 at position 9, 3 at position 10, 2 at position 8 (all inside window). Evict the page used farthest in the window (page 3). Frames become [4, 1, 2]. Page fault (total = 5).
Access page 2. Page 2 is in frames. Hit (total faults = 5).
Access page 4. Page 4 is in frames. Hit (total faults = 5).
Access page 3. Lookahead window: [3, 1, 4] (sequence ends after these). Pages in frames: [4, 1, 2]. Page 2 is not used inside this window, so evict page 2. Frames become [4, 1, 3]. Page fault (total = 6).
Access page 1. Page 1 is in frames. Hit (total faults = 6).
Access page 4. Page 4 is in frames. Hit (total faults = 6).
Answer: 6
A video solution is available for this question — log in and enroll to watch it.
- Q7.GATE 2025
Consider a demand paging memory management system with 32-bit logical address, 20-bit physical address, and page size of 2048 bytes. Assuming that the memory is byte addressable, what is the maximum number of entries in the page table?
- A.
221
- B.
220
- C.
222
- D.
224
Correct answer: A
Solution
Answer: 2^21 (2 to the power 21) = 2,097,152 entries.
Explanation: A page table has one entry for every page in the process's logical address space. So the number of entries equals the total logical address space divided by the page size.
Logical address space: 32-bit addresses ⇒ total size = 2^32 bytes.
Page size: 2048 bytes = 2^11 bytes.
Number of pages (and page table entries): 2^32 / 2^11 = 2^(32−11) = 2^21.
Therefore the maximum number of entries in the page table is 2^21, which equals 2,097,152 entries.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q8.GATE 2025
A computer system supports a logical address space of 232 bytes. It uses two-level hierarchical paging with a page size of 4096 bytes. A logical address is divided into a 𝑏-bit index to the outer page table, an offset within the page of the inner page table, and an offset within the desired page. Each entry of the inner page table uses eight bytes. All the pages in the system have the same size.
The value of 𝑏 is ___________ . (Answer in integer)
Correct answer: 11
Solution
Correct Answer is 11.
This question asks you to determine the size, in bits, of the index for the outer page table (represented by the variable b). The system uses a 32-bit logical address and a two-level paging scheme. To find b, you must first calculate the number of bits required for the other two parts of the address: the page offset and the inner page table index, using the given page size and page table entry size.
A 32-bit logical address in this system is divided into three parts:
[ Outer Page Index (b bits) | Inner Page Table Index (x bits) | Page Offset (d bits) ]
<------------------------32 Bit total (b + x + d ) --------------------------------->
1. Find the Page Offset (d)
The page offset is determined by the size of a page.
Page Size = 4096 Bytes = 212 Bytes.
To address each of the 4096 bytes within a page, you need 12 bits.
Therefore, d = 12 bits.
2. Find the Inner Page Table Index (x)
An inner page table must fit perfectly into a single page frame. We can use this to find how many bits are needed for its index.
Number of Entries in an Inner Table = Page Size / Entry Size = 4096 Bytes / 8 Bytes = 512 entries.
To uniquely address 512 entries, you need log2(512) bits, which is 9 bits.
Therefore, x = 9 bits.
3. Find the Outer Page Table Index (b)
The outer index b consists of the remaining bits of the 32-bit address.
b + x + d = 32
b + 9 + 12 = 32
b + 21 = 32
b = 32 - 21 = 11
The value of b is 11.
A video solution is available for this question — log in and enroll to watch it.
- Q9.GATE 2025
Ravi had ______ younger brother who taught at ______ university. He was widely regarded as ______ honorable man.
Select the option with the correct sequence of articles to fill in the blanks.
- A.
a; a; an
- B.
the; an; a
- C.
a; an; a
- D.
an; an; a
Correct answer: A
Solution
Answer: a; a; an
Filled sentence: Ravi had a younger brother who taught at a university. He was widely regarded as an honorable man.
First blank: use "a" because "younger" begins with a consonant sound (/j/), so "a younger brother" is correct.
Second blank: use "a" before "university" because the word begins with the consonant sound /j/ (so the choice depends on pronunciation, not the first letter).
Third blank: use "an" before "honorable" because the initial "h" is silent and the word begins with a vowel sound, so "an honorable man" is correct.
Tip: choose "a" or "an" based on the initial sound of the following word. Use "the" only when referring to something specific or already mentioned.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q10.GATE 2025
The CEO’s decision to downsize the workforce was considered myopic because it sacrificed long-term stability to accommodate short-term gains.
Select the most appropriate option that can replace the word “myopic” without changing the meaning of the sentence.
- A.
visionary
- B.
shortsighted
- C.
progressive
- D.
innovative
Correct answer: B
Solution
Answer: shortsighted
"Myopic" means lacking long-term perspective or foresight, focusing instead on immediate results. In the sentence, the CEO sacrificed long-term stability for short-term gains, which shows a short-term focus.
Why "shortsighted" is correct: "shortsighted" directly matches the idea of prioritizing short-term benefits over future stability.
Why "visionary" is wrong: "visionary" means far-sighted and forward-looking, the opposite of "myopic."
Why "progressive" is wrong: "progressive" implies moving forward or favoring reform, not lacking foresight.
Why "innovative" is wrong: "innovative" describes creativity or new methods, and does not convey short-term thinking.
Conclusion: "shortsighted" best preserves the original meaning of "myopic" as used in the sentence.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q11.GATE 2025
The average marks obtained by a class in an examination were calculated as 30.8. However, while checking the marks entered, the teacher found that the marks of one student were entered incorrectly as 24 instead of 42. After correcting the marks, the average becomes 31.4. How many students does the class have?
- A.
25
- B.
28
- C.
30
- D.
32
Correct answer: C
Solution
Key idea: The correction changes the total marks by the difference between the correct and incorrect entries, and the change in average equals that change in total divided by the number of students.
Compute the increase in total marks: 42 - 24 = 18.
Compute the increase in average: 31.4 - 30.8 = 0.6.
Let n be the number of students. The increase in average equals the increase in total divided by n, so 18 / n = 0.6.
Solve for n: n = 18 / 0.6 = 30.
Conclusion: The class has 30 students.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q12.GATE 2025
Consider the relationships among P, Q, R, S, and T:
• P is the brother of Q.
• S is the daughter of Q.
• T is the sister of S.
• R is the mother of Q.
The following statements are made based on the relationships given above.
(1) R is the grandmother of S.
(2) P is the uncle of S and T.
(3) R has only one son.
(4) Q has only one daughter.
Which one of the following options is correct?
- A.
Both (1) and (2) are true.
- B.
Both (1) and (3) are true.
- C.
Only (3) is true.
- D.
Only (4) is true.
Correct answer: A
Solution
Given relationships:
P is the brother of Q.
S is the daughter of Q.
T is the sister of S (so T is also a child of Q and female).
R is the mother of Q.
Evaluate each statement:
R is the grandmother of S: True. R is the mother of Q and S is Q's daughter, so R is S's grandmother.
P is the uncle of S and T: True. P is the brother of Q, and S and T are Q's children, so P is their uncle.
R has only one son: Cannot be concluded / False as a necessary statement. The given facts do not state how many sons or children R has, so you cannot assert that R has only one son.
Q has only one daughter: False. The information names two daughters of Q (S and T), so Q has at least two daughters.
Correct answer: Both (1) and (2) are true.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q13.GATE 2025
According to the map shown in the figure, which one of the following statements is correct?
Note: The figure shown is representative.

- A.
The library is located to the northwest of the canteen.
- B.
The hospital is located to the east of the chemistry lab.
- C.
The chemistry lab is to the southeast of physics lab.
- D.
The classrooms and canteen are next to each other.
Correct answer: C
Solution
Answer: The library is located to the northwest of the canteen.
Explanation:
Identify quadrants using the two roads: the vertical road is the main road and the horizontal road is the cross road. The upper-right area is northeast, upper-left is northwest, lower-left is southwest, and lower-right is southeast.
The canteen is in the upper-right quadrant (northeast): it lies to the east of the main road and north of the cross road.
The library is in the upper-left quadrant (northwest): it lies to the west of the main road and north of the cross road.
Comparing the two positions shows the library is to the west and (also) to the north of the canteen, so the library is northwest of the canteen.
Brief checks of the other statements:
Hospital vs chemistry lab: The hospital is above (north of) the chemistry lab on the right side of the map, so it is not to the east of the chemistry lab.
Chemistry lab vs physics lab: The physics lab is in the upper-left quadrant and the chemistry lab is in the lower-right quadrant; they are diagonally opposite across both roads. This diagonal relation means you move east and south to go from the physics lab to the chemistry lab, but the question's clearly unambiguous statement about the library and canteen is the intended single correct choice.
Classrooms and canteen: The classrooms are in the lower-left quadrant while the canteen is in the upper-right quadrant, so they are not next to each other.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q14.GATE 2025
“I put the brown paper in my pocket along with the chalks, and possibly other things. I suppose every one must have reflected how primeval and how poetical are the things that one carries in one’s pocket: the pocket-knife, for instance the type of all human tools, the infant of the sword. Once I planned to write a book of poems entirely about the things in my pocket. But I found it would be too long: and the age of the great epics is past.”
(From G.K. Chesterton’s “A Piece of Chalk”)
Based only on the information provided in the above passage, which one of the following statements is true?
- A.
The author of the passage carries a mirror in his pocket to reflect upon things.
- B.
The author of the passage had decided to write a poem on epics.
- C.
The pocket-knife is described as the infant of the sword.
- D.
Epics are described as too inconvenient to write.
Correct answer: C
Solution
Answer: The pocket-knife is described as the infant of the sword.
Explanation: The passage explicitly calls the pocket-knife "the infant of the sword," so the statement that the pocket-knife is described in that way is directly supported by the text.
The claim that the author carries a mirror to reflect upon things is not supported: the passage lists brown paper, chalks, and the pocket-knife and uses the verb "reflected" to mean people have thought about the pocket contents, not that a mirror is carried.
The claim that the author had decided to write a poem on epics is incorrect: the passage says he planned a book of poems about the things in his pocket, and separately notes that "the age of the great epics is past," so epics are not presented as his intended subject.
The claim that epics are described as too inconvenient to write is incorrect: the passage says the planned pocket-themed book "would be too long" and that the age of great epics is past, but it does not describe epics as inconvenient to write.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q15.GATE 2025
In the diagram, the lines QR and ST are parallel to each other. The shortest distance between these two lines is half the shortest distance between the point P and line QR. What is the ratio of the area of the triangle PST to the area of the trapezium SQRT?
Note: The figure shown is representative.

- A.
\(1\over 3\) - B.
\(1\over 4\) - C.
\(2 \over 5\) - D.
\(1\over 2\)
Correct answer: A
Solution
Key idea: use similarity of triangles and area scaling.
Let the base QR have length B. Let the shortest distance from P to QR be 2d, so the distance between the lines ST and QR is d. Then the distance from P to ST is 2d − d = d.
Triangles PST and PQR are similar because ST is parallel to QR. The linear scale factor is (height from P to ST)/(height from P to QR) = d/(2d) = 1/2, so ST = (1/2)·QR.
Areas scale as the square of the linear factor, so area(PST) = (1/2)^2 · area(PQR) = 1/4 · area(PQR).
The trapezium SQRT is the part of triangle PQR below ST, so area(SQRT) = area(PQR) − area(PST) = (1 − 1/4)·area(PQR) = 3/4·area(PQR).
Therefore the ratio area(PST) : area(SQRT) = (1/4) : (3/4) = 1 : 3 = 1/3.
Answer: 1/3
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q16.GATE 2025
A fair six-faced dice, with the faces labelled ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, and ‘6’, is rolled thrice. What is the probability of rolling ‘6’ exactly once?
- A.
\(75 \over {216}\) - B.
\(1 \over {6}\) - C.
\(1 \over {18}\) - D.
\(25 \over {216}\)
Correct answer: A
Solution
Correct probability:
Use the binomial reasoning. Exactly one '6' in three rolls means choose which one of the three rolls is the six, and the other two must not be six.
Number of ways to choose the roll that shows 6: 3
Probability for a specific chosen pattern (one fixed position is 6 and the other two are not): (1/6) * (5/6) * (5/6) = 25/216
Multiply by the 3 possible positions: 3 * 25/216 = 75/216 = 25/72 ≈ 0.3472
Therefore the probability of rolling '6' exactly once in three rolls is 75/216, which simplifies to 25/72.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q17.GATE 2025
A square paper, shown in figure (I), is folded along the dotted lines as shown in the figures (II) and (III). Then a few cuts are made as shown in figure (IV). Which one of the following patterns will be obtained when the paper is unfolded?
Note: The figures shown are representative.

Solution
Key insight: each fold mirrors the paper, so each cut on the small folded wedge is reproduced by reflections when the paper is unfolded.
First fold (diagonal): the square becomes a right isosceles triangle. Anything cut on the folded piece will be mirrored across the diagonal when unfolded.
Second fold (triangle folded again): the triangle is reduced to a smaller triangular wedge. Cuts made at this stage lie in that wedge and will be reflected across both fold lines when the paper is fully opened.
Unfolding sequence: first undo the second fold to get the right triangle with mirrored cuts, then undo the diagonal fold to get the full square. Each cut on the wedge therefore produces multiple symmetric copies on the full square.
The small square-shaped cut near the pointed tip of the wedge becomes a square mark at each of the four corners of the full square.
The triangular cut near the hypotenuse of the wedge becomes a triangular mark at the midpoint of each side of the full square (because it is reflected across the fold lines to the four side midpoints).
Conclusion: The unfolded pattern must show square marks at the four corners and triangular marks at the midpoint of each side. The image that displays small squares at each corner and small triangles at the midpoints of the sides is the correct unfolded result.
A video solution is available for this question — log in and enroll to watch it.
- Q18.GATE 2025
A shop has 4 distinct flavors of ice-cream. One can purchase any number of scoops of any flavor. The order in which the scoops are purchased is inconsequential. If one wants to purchase 3 scoops of ice-cream, in how many ways can one make that purchase?
- A.
4
- B.
20
- C.
24
- D.
48
Correct answer: B
Solution
Answer: 20
Explanation: We need the number of ways to choose 3 scoops from 4 distinct flavors when repetition is allowed and order does not matter. This is the number of multisets of size 3 from 4 types.
Use the combinations with repetition formula (stars and bars): the number is C(n + k - 1, k), where n = number of flavors and k = number of scoops.
Here n = 4 and k = 3, so the count is C(4 + 3 - 1, 3) = C(6, 3).
Compute C(6,3) = 6*5*4 / (3*2*1) = 120 / 6 = 20.
Quick notes on the incorrect numerical choices:
The value 4 counts only the cases where all three scoops are the same flavor (one per flavor).
The value 24 is 4P3, counting ordered selections of three distinct flavors with no repetition; that assumes order matters and repeats are forbidden, which does not match the problem.
The value 48 does not follow from the correct model and likely comes from mixing different incorrect assumptions about order and repetition.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q19.GATE 2025
Suppose a program is running on a non-pipelined single processor computer system. The computer is connected to an external device that can interrupt the processor asynchronously. The processor needs to execute the interrupt service routine (ISR) to serve this interrupt. The following steps (not necessarily in order) are taken by the processor when the interrupt arrives:
(i) The processor saves the content of the program counter.
(ii) The program counter is loaded with the start address of the ISR.
(iii) The processor finishes the present instruction.
Which ONE of the following is the CORRECT sequence of steps?
- A.
(iii), (i), (ii)
- B.
(i), (iii), (ii)
- C.
(i), (ii), (iii)
- D.
(iii), (ii), (i)
Correct answer: A
Solution
Correct sequence: finish the current instruction, save the program counter, then load the program counter with the ISR start address.
Finish the current instruction: A non-pipelined single-processor system cannot be interrupted mid-instruction, so the processor must complete the instruction that was executing when the interrupt arrived.
Save the program counter: After the instruction completes the program counter points to the next instruction to execute; saving it preserves the correct return address for when the ISR finishes.
Load the program counter with the ISR start address: With the return address saved, the PC can be set to the interrupt service routine entry so the ISR runs. On return, the saved PC is restored to resume the interrupted execution.
Why other orders fail: Saving the PC before finishing the instruction can record an incorrect return address, and loading the ISR address before saving the PC overwrites the return address so it cannot be restored. Both mistakes prevent correct resumption of the interrupted program.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q20.GATE 2025
Which ONE of the following statements is FALSE regarding the symbol table?
- A.
Symbol table is responsible for keeping track of the scope of variables.
- B.
Symbol table can be implemented using a binary search tree.
- C.
Symbol table is not required after the parsing phase.
- D.
Symbol table is created during the lexical analysis phase.
Correct answer: C
Solution
Correct answer: The statement "Symbol table is not required after the parsing phase." is FALSE.
Why this is false: The symbol table is needed after parsing for semantic analysis (for example, type checking and scope resolution), for generating intermediate or target code, for optimization passes that rely on symbol information, and sometimes during linking or runtime activities. Therefore it is not limited to the parsing phase.
Clarification of the other statements:
A symbol table is responsible for tracking scopes, types, and other attributes of identifiers; this supports correct name resolution.
A symbol table can be implemented using a binary search tree, though hash tables are often chosen for faster average lookups. Balanced BSTs give ordered traversal and guaranteed logarithmic time.
The symbol table may start getting entries when identifiers are first seen (even at lexical analysis), but full population, scope management, and semantic attributes are generally established during parsing and semantic analysis.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q21.GATE 2025
Which ONE of the following techniques used in compiler code optimization uses live variable analysis?
- A.
Run-time function call management
- B.
Register assignment to variables
- C.
Strength reduction
- D.
Constant folding
Correct answer: B
Solution
Correct answer: Register assignment to variables (register allocation).
Why: Live variable analysis is a backward data-flow analysis that computes, at each program point, which variables may be used in the future (the live-in and live-out sets). It identifies the live ranges of variables, and that information is essential for register allocation.
Builds the interference graph: two variables that are live at the same time interfere and cannot share a register.
Guides spilling decisions: variables with large live ranges or high interference are candidates to be moved to memory.
Helps register coalescing and other allocation heuristics by revealing when variables do not overlap in time.
Notes on the other choices:
Run-time function call management deals with calling conventions, stack frames, and parameter passing; it is not driven by live variable analysis.
Strength reduction is a local arithmetic optimization (e.g., replacing multiplication with addition) and does not require liveness information.
Constant folding evaluates constant expressions at compile time and does not depend on live variable analysis.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q22.GATE 2025
A schedule of three database transactions
\(𝑇_1, 𝑇_2\), and\(𝑇_3\)is shown.\(𝑅_𝑖(𝐴)\)and\(𝑊_𝑖(𝐴)\)denote read and write of data item\(𝐴\)by transaction\(𝑇_𝑖 , 𝑖 = 1,2,3\). The transaction\(𝑇_1\)aborts at the end. Which other transaction(s) will be required to be rolled back?\(𝑅_1 (𝑋) 𝑊_1 (𝑌) 𝑅_2 (𝑋) 𝑅_2 (𝑌) 𝑅_3 (𝑌) 𝐴𝐵𝑂𝑅𝑇(𝑇_1 )\)- A.
Only
\(𝑇_2\) - B.
Only
\(𝑇_3\) - C.
Both
\(𝑇_2\)and\(𝑇_3\) - D.
Neither
\(𝑇_2\)nor\(𝑇_3\)
Correct answer: C
Solution
Answer: Both transactions T2 and T3 must be rolled back.
Explanation:
Identify the relevant operations in order: T1 writes Y (W1(Y)) occurs before the reads R2(Y) and R3(Y).
If a transaction aborts, any transaction that has read a value written by that aborted transaction must be rolled back to prevent cascading inconsistency (they read an uncommitted value).
Both T2 and T3 read Y after W1(Y), so they both read a value produced by T1. Therefore both T2 and T3 must be rolled back when T1 aborts.
Note: T2's read of X is unaffected because T1 did not write X; only reads of the aborted transaction's writes force rollbacks.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q23.GATE 2025
Identify the ONE CORRECT matching between the OSI layers and their corresponding functionalities as shown.
\(\begin{array}{|l|l|} \hline \textbf{OSI Layer} & \textbf{Functionality} \\ \hline (a) Network layer & (I) Packet routing \\ \hline (b) Transport layer & (II) Framing and error handling \\ \hline (c) Datalink layer & (III) Host to host communication \\ \hline \end{array} \)- A.
\((a)-(I), (b)-(II), (c)-(III) \) - B.
\((a)-(I), (b)-(III), (c)-(II)\) - C.
\((a)-(II), (b)-(I), (c)-(III)\) - D.
\((a)-(III), (b)-(II), (c)-(I)\)
Correct answer: B
Solution
Concept: Each OSI layer's responsibility is defined by the scope over which it operates. Layer 2 (Data Link) governs a single physical or logical link; Layer 3 (Network) governs path selection across possibly many interconnected networks between links; Layer 4 (Transport) governs delivery across the complete path between the two communicating end systems, independent of the number of intermediate hops.
Application: Apply that scope test to each named functionality and match it to the layer whose scope it fits:
Packet routing selects a forwarding path using logical addresses and can span several interconnected networks → this is the Network layer's scope, so Network layer → Packet routing.
Host-to-host communication delivers data reliably and in order all the way from the originating system to the destination system, regardless of intermediate hops → this is the Transport layer's scope, so Transport layer → Host-to-host communication.
Framing and error handling organises the bit stream into frames and detects/corrects errors introduced during transmission over one link → this is the Datalink layer's scope, so Datalink layer → Framing and error handling.
Cross-check: Order the three functions by operating scope from narrowest to widest: framing (single link) < packet routing (path across networks) < host-to-host communication (full end-to-end path). This scope ordering matches the stack order Datalink (Layer 2) < Network (Layer 3) < Transport (Layer 4), independently confirming the same mapping.
Result: Network → Packet routing, Transport → Host-to-host communication, Datalink → Framing and error handling, i.e. (a)→(I), (b)→(III), (c)→(II).
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q24.GATE 2025
\(𝑔(. )\)is a function from\(A\)to\(𝐵, 𝑓(. )\)is a function from\(B\)to\(C\), and their composition defined as\(𝑓(𝑔(. ))\)is a mapping from\(A\)to\(C\). If\(𝑓(. )\)and\(𝑓(𝑔(. ))\)are onto (surjective) functions, which ONE of the following is TRUE about the function\(𝑔(. )\)?- A.
\(𝑔(. )\)must be an onto (surjective) function. - B.
\(𝑔(. )\)must be a one-to-one (injective) function. - C.
\(𝑔(. )\)must be a bijective function, that is, both one-to-one and onto. - D.
\(𝑔(. )\)is not required to be a one-to-one or onto function.
Correct answer: D
Solution
Correct conclusion: g is not required to be a one-to-one or onto function.
Explanation:
If f∘g is onto C, then for every c in C there exists some a in A with f(g(a)) = c. This means f maps the image of g (a subset of B) onto C, i.e. f(image(g)) = C. It does not force image(g) to equal all of B, nor does it force g to be injective.
Counterexample showing g need not be onto: Let C = {c}, B = {b1, b2}, A = {a}. Define f(b1) = c and f(b2) = c (so f is onto C). Define g(a) = b1. Then f∘g(a) = c, so f∘g is onto C, but g does not hit b2 and so is not onto B.
Counterexample showing g need not be injective: Let B = {b}, C = {c}, A = {a1, a2}. Define f(b) = c (so f is onto). Define g(a1) = g(a2) = b. Then f∘g maps both a1 and a2 to c, so f∘g is onto, but g is not injective.
Key point: what must hold is that the image of g is large enough that f(image(g)) = C; g itself need not be onto B or one-to-one.
- A.
- Q25.GATE 2025
Let
\(G\)be any undirected graph with positive edge weights, and\(𝑇\)be a minimum spanning tree of\(G\). For any two vertices,\(𝑢\)and\(𝑣\), let\(𝑑_1(𝑢, 𝑣)\)and\(𝑑_2(𝑢, 𝑣)\)be the shortest distances between\(u\)and\(𝑣\)in\(G\)and 𝑇, respectively. Which ONE of the options is CORRECT for all possible\(𝐺, 𝑇, 𝑢\)and\(𝑣\)?- A.
\(d_1(u, v) = d_2(u, v)\) - B.
\(d_1(u, v) \leq d_2(u, v)\) - C.
\(d_1(u, v) \geq d_2(u, v)\) - D.
\(d_1(u, v) \neq d_2(u, v)\)
Correct answer: B
Solution
Claim: For every pair of vertices u and v, d1(u, v) ≤ d2(u, v).
Proof:
The minimum spanning tree T is a subgraph of G, so the unique path in T between u and v is also a path in G.
The length of that path in T equals d2(u, v). Since d1(u, v) is the length of the shortest path in G, we must have d1(u, v) ≤ d2(u, v).
So the correct universal statement is d1(u, v) ≤ d2(u, v).
Example showing strict inequality can occur:
Take three vertices u, v, w with edge weights: u–v = 1, u–w = 2, w–v = 2.
An MST can include edges u–v (1) and u–w (2), leaving out the direct edge w–v. Then d2(w, v) (distance in the tree) = 3, while d1(w, v) (shortest in G) = 2 via the direct edge w–v.
Conclusion: The universally correct relation is d1(u, v) ≤ d2(u, v).
- A.
- Q26.GATE 2025
Consider the following context-free grammar
\(G\), where\(𝑆, 𝐴,\)and\(B\)are the variables (non-terminals),\(a\)and\(b\)are the terminal symbols,\(S\)is the start variable, and the rules of\(G\)are described as:\(𝑆 → 𝑎𝑎𝐵 | 𝐴𝑏𝑏 \\ \\𝐴 → 𝑎 | 𝑎𝐴 \\ \\𝐵 → 𝑏 | 𝑏B \\\)Which ONE of the languages
\(𝐿(𝐺)\)is accepted by\(G\)?- A.
\(L(G) = \{ a^{2} b^n \mid n \geq 1 \} \cup \{ a^n b^2 \mid n \geq 1 \}\) - B.
\(L(G) = \{ a^n b^{2n} \mid n \geq 1 \} \cup \{ a^{2n} b^n \mid n \geq 1 \}\) - C.
\(L(G) = \{ a^n b^n \mid n \geq 1 \}\) - D.
\(L(G) = \{ a^{2n} b^{2n} \mid n \geq 1 \}\)
Correct answer: A
Solution
What A Generates:
A → a | aA (left-recursive) produces a^k for k ≥ 1 (one or more a's).
E.g., A ⇒ a, A ⇒ aa, A ⇒ aaa, etc.What B Generates:
B → b | bB (right-recursive) produces b^m for m ≥ 1 (one or more b's).
E.g., B ⇒ b, B ⇒ bb, B ⇒ bbb, etc.From S → aaB:
S ⇒ aaB ⇒ aa b^m (m ≥ 1).
So, strings of the form a^2 b^m where m ≥ 1.From S → Abb:
S ⇒ Abb ⇒ A bb ⇒ a^k bb (k ≥ 1).
So, strings of the form a^k b^2 where k ≥ 1.Overall L(G):
L(G) = {a^2 b^m | m ≥ 1} ∪ {a^k b^2 | k ≥ 1}.
This matches option A: {a^{2n} | n ≥ 1} ∪ {a^n b^2 | n ≥ 1}A video solution is available for this question — log in and enroll to watch it.
- A.
- Q27.GATE 2025
Consider the following recurrence relation:
\(T(n) = 2T(n - 1) + n 2^n, \quad \text{for } n > 0, \quad T(0) = 1. \)Which ONE of the following options is CORRECT?
- A.
\(T(n) = \Theta(n^2 2^n) \) - B.
\(T(n) = \Theta(n 2^n) \) - C.
\(T(n) = \Theta((\log n)^2 2^n) \) - D.
\(T(n) = \Theta(4^n)\)
Correct answer: A
Solution
Key idea: simplify the recurrence by dividing by 2^n.
Let S(n) = T(n)/2^n. Then
S(n) = T(n)/2^n = (2T(n-1))/2^n + n^2 = T(n-1)/2^{n-1} + n^2 = S(n-1) + n^2.
Unrolling gives S(n) = S(0) + sum_{i=1}^n i^2 = 1 + sum_{i=1}^n i^2.
Use the formula sum_{i=1}^n i^2 = n(n+1)(2n+1)/6 = Theta(n^3). So S(n) = 1 + Theta(n^3) = Theta(n^3).
Therefore T(n) = 2^n * S(n) = 2^n * Theta(n^3) = Theta(n^3 2^n).
Conclusion: The recurrence solves to Theta(n^3 2^n). The provided option that states Theta(n^2 2^n) underestimates the polynomial factor; the Theta(n 2^n) and Theta((log n)^2 2^n) options are also too small. Theta(4^n) is far too large since the recurrence produces 2^n times a polynomial factor, not an exponential 4^n growth.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q28.GATE 2025
Consider the following
\(B^+\)tree with 5 nodes, in which a node can store at most 3 key values. The value 23 is now inserted in the\(B^+\)tree. Which of the following options(s) is/are CORRECT?
- A.
None of the nodes will split.
- B.
At least one node will split and redistribute.
- C.
The total number of nodes will remain same.
- D.
The height of the tree will increase.
Correct answer: B, D
Solution
Solution:
Step-by-step reasoning for inserting 23 into the given B+ tree (maximum 3 keys per node):
Locate the leaf for 23: the rightmost leaf currently holds 20, 21, 22 (three keys).
Insert 23 into that leaf would produce four keys (20, 21, 22, 23), which exceeds the allowed maximum of three, so the leaf must split.
Typical split of the overflowed leaf yields two leaves with two keys each, for example [20, 21] and [22, 23]. In a B+ tree the first key of the new right leaf (22) is promoted to the parent as a separator.
Promoting 22 to the parent (the root) makes the root hold keys 6, 12, 19, 22 (four keys), which exceeds the maximum of three keys for an internal node, so the root must also split.
Splitting the root produces two internal nodes and a new root above them. Creating a new root increases the height of the tree by one.
Consequences (summary):
A leaf node splits (so it is false that no node will split).
Redistribution (borrowing keys from a sibling) is not possible here because neighboring leaves are full, so the action taken is splitting rather than redistribution.
The root splits and a new root is created, so the height increases by one.
The total number of nodes increases (example counts: start with 5 nodes; after leaf split -> 6; after root split -> 8).
Final evaluation of the given statements:
"None of the nodes will split." — Incorrect.
"At least one node will split and redistribute." — Incorrect (a split occurs but redistribution does not).
"The total number of nodes will remain same." — Incorrect (node count increases due to splits).
"The height of the tree will increase." — Correct.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q29.GATE 2025
Consider the 3-way handshaking protocol for TCP connection establishment. Let the three packets exchanged during the connection establishment be denoted as P1, P2, and P3, in order. Which of the following option(s) is/are TRUE with respect to TCP header flags that are set in the packets?
- A.
P3: SYN = 1, ACK = 1
- B.
P2: SYN = 1, ACK = 1
- C.
P2: SYN = 0, ACK = 1
- D.
P1: SYN = 1
Correct answer: B, D
Solution
Correct statements: P2: SYN = 1, ACK = 1 and P1: SYN = 1
Three-way handshake (flags and purpose):
Packet 1 (client -> server): P1 sets SYN = 1. This is the initial connection request and carries the client's initial sequence number. The ACK bit is not set (ACK = 0).
Packet 2 (server -> client): P2 sets SYN = 1 and ACK = 1. The server replies with a SYN+ACK to advertise its own sequence number and to acknowledge the client's SYN (acknowledgement number = client ISN + 1).
Packet 3 (client -> server): P3 sets ACK = 1 and SYN = 0. The client acknowledges the server's SYN (acknowledgement number = server ISN + 1) and does not set SYN.
Why the other statement is false:
The statement "P3: SYN = 1, ACK = 1" is incorrect because the final packet from the client is an ACK-only packet (SYN = 0).
The statement "P2: SYN = 0, ACK = 1" is incorrect because the server's reply includes its own SYN, so P2 has SYN = 1 and ACK = 1.
Summary: The correct flag settings are: P1 (client) SYN = 1, ACK = 0; P2 (server) SYN = 1, ACK = 1; P3 (client) SYN = 0, ACK = 1.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q30.GATE 2025
Consider the given system of linear equations for variables
\(x\)and\(y\), where\(k\)is a real-valued constant. Which of the following option(s) is/are CORRECT?\(𝑥 + 𝑘𝑦 = 1 \\ 𝑘𝑥 + 𝑦 = −1\)- A.
There is exactly one value of 𝑘 for which the above system of equations has no solution.
- B.
There exist an infinite number of values of 𝑘 for which the system of equations has no solution.
- C.
There exists exactly one value of 𝑘 for which the system of equations has exactly one solution.
- D.
There exists exactly one value of 𝑘 for which the system of equations has an infinite number of solutions.
Correct answer: A, D
Solution
Compute the determinant of the coefficient matrix to classify the system.
Determinant = 1 - k^2. If this determinant is nonzero (k ≠ ±1) the system has a unique solution; if it is zero (k = ±1) investigate consistency.
Case k = 1: The equations become x + y = 1 and x + y = -1. These are inconsistent (they assert two different values for x + y), so there is no solution.
Case k = -1: The equations become x - y = 1 and -x + y = -1. The second equation is just −1 times the first, so the two equations are dependent and the system has infinitely many solutions (one free parameter). For example, set y = t, then x = 1 + t.
Case k ≠ ±1: The determinant is nonzero, so the system has exactly one solution. Using Cramer's rule gives x = 1/(1 - k) and y = -1/(1 - k), which are well defined for k ≠ ±1.
Conclusion: The system has no solution only at k = 1; it has infinitely many solutions only at k = -1; and it has a unique solution for every other real k. Therefore the correct statements are those that assert exactly one value of k gives no solution (k = 1) and exactly one value of k gives infinitely many solutions (k = -1).
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q31.GATE 2025
Let
\(𝑋\)be a 3-variable Boolean function that produces output as ‘1’ when at least two of the input variables are ‘1’. Which of the following statement(s) is/are CORRECT, where\( 𝑎, 𝑏, 𝑐, 𝑑,𝑒\)are Boolean variables?- A.
\(𝑋(𝑎, 𝑏, 𝑋(𝑐, 𝑑,𝑒)) = 𝑋(𝑋(𝑎, 𝑏, 𝑐), 𝑑,𝑒)\) - B.
\(𝑋(𝑎, 𝑏, 𝑋(𝑎, 𝑏, 𝑐)) = 𝑋(𝑎, 𝑏, 𝑐)\) - C.
\(𝑋(𝑎, 𝑏, 𝑋(𝑎, 𝑐, 𝑑)) = (𝑋(𝑎, 𝑏, 𝑎) AND 𝑋(𝑐, 𝑑, 𝑐))\) - D.
\(𝑋(𝑎, 𝑏, 𝑐) = 𝑋(𝑎, 𝑋(𝑎, 𝑏, 𝑐), 𝑋(𝑎, 𝑐, 𝑐))\)
Correct answer: B, D
Solution
Summary of correct identities for X, the 3-variable majority function (output 1 when at least two inputs are 1):
The equality X(a, b, X(a, b, c)) = X(a, b, c) is correct. Reason: consider cases on a and b. If a and b are both 1 the value is 1; if both 0 the value is 0; if exactly one of a and b is 1 then X(a,b,c) = c and substituting yields the same value. Thus the inner repetition does not change the majority.
The equality X(a, b, c) = X(a, X(a, b, c), X(a, c, c)) is correct. Reason: X(a,c,c) = c because two copies of c determine the majority, so the right-hand side becomes X(a, t, c) with t = X(a,b,c). One checks that X(a,t,c) = t by a short case analysis: if a = c then t = a and both sides equal a; if a ≠ c, then t = majority(a,b,c) is the same value returned by majority(a,t,c). This follows from the idempotent/absorbing behavior of the majority operator.
The equality X(a, b, X(c, d, e)) = X(X(a, b, c), d, e) is not correct. Counterexample: a = 0, b = 0, c = d = e = 1. Then X(c,d,e) = 1, so left side X(0,0,1) = 0, while X(a,b,c) = 0 gives right side X(0,1,1) = 1. The two sides differ.
The equality X(a, b, X(a, c, d)) = (X(a, b, a) AND X(c, d, c)) is not correct. Simplify the right-hand side: X(a,b,a) = a and X(c,d,c) = c, so RHS = a AND c. Counterexample: a = 1, b = 0, c = 0, d = 1 gives left side X(1,0,X(1,0,1)) = X(1,0,1) = 1, while RHS = 1 AND 0 = 0.
Final answer: the correct statements are the ones asserting X(a, b, X(a, b, c)) = X(a, b, c) and X(a, b, c) = X(a, X(a, b, c), X(a, c, c)).
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q32.GATE 2025
The number −6 can be represented as 1010 in 4-bit 2’s complement representation. Which of the following is/are CORRECT 2’s complement representation(s) of −6?
- A.
1000 1010 in 8-bits
- B.
1111 1010 in 8-bit
- C.
1000 0000 0000 1010 in 16-bits
- D.
1111 1111 1111 1010 in 16-bits
Correct answer: B, D
Solution
Correct 2's complement representations of −6: 11111010 (8-bit) and 1111111111111010 (16-bit).
Start from the 4-bit two's complement 1010, which represents −6. To extend to a larger bit width, replicate the sign bit (the leftmost bit) into the new high-order bits.
8-bit extension: replicate the sign bit 1 to get 11111010. Check by two's-complement: invert to 00000101 and add 1 to get 00000110 (6), so the value is −6.
16-bit extension: replicate the sign bit 1 to get 1111111111111010. Check by two's-complement: invert to 0000000000000101 and add 1 to get 0000000000000110 (6), so the value is −6.
Why the other patterns are wrong: 10001010 (8-bit) and 1000000000001010 (16-bit) do not perform correct sign extension from 1010 and therefore represent different negative values.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q33.GATE 2025
Which of the following statement(s) is/are TRUE for any binary search tree (BST) having 𝑛 distinct integers?
- A.
The maximum length of a path from the root node to any other node is
\((𝑛 − 1)\). - B.
An inorder traversal will always produce a sorted sequence of elements
- C.
Finding an element takes
\(𝑂(log_2 𝑛)\)time in the worst case. - D.
Every BST is also a Min-Heap.
Correct answer: A, B
Solution
Correct statements for any binary search tree (BST) with n distinct integers:
The maximum length of a path from the root node to any other node is n−1.
An inorder traversal will always produce a sorted sequence of elements.
Why these are true:
Maximum path length equals n−1 because in the most unbalanced case the BST degenerates into a single chain (each node has only one child), so the longest root-to-node path visits all other nodes. Note: this counts edges; counting nodes would give n.
Inorder traversal visits left subtree, then the node, then right subtree recursively. The BST property (all left subtree keys < node key < all right subtree keys) ensures the visited sequence is in ascending order.
Why the other statements are incorrect:
Finding an element takes O(log n) time only in balanced BSTs. In the worst case (an unbalanced BST that is a chain) search degrades to O(n).
A BST is not necessarily a min-heap. A min-heap requires each parent to be ≤ its children, which is a different constraint. A BST can have a parent larger than a descendant in the right subtree's left branch, so it may violate the heap property (for example a node with key 15 can have a descendant with key 12).
Final answer: The true statements are the ones about the maximum path length being n−1 and that inorder traversal produces a sorted sequence. The time-complexity statement is only true for balanced BSTs, and the min-heap statement is false.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q34.GATE 2025
A partial data path of a processor is given in the figure, where RA, RB, and RZ are 32-bit registers. Which option(s) is/are CORRECT related to arithmetic operations using the data path as shown?

- A.
The data path can implement arithmetic operations involving two registers.
- B.
The data path can implement arithmetic operations involving one register and one immediate value.
- C.
The data path can implement arithmetic operations involving two immediate values.
- D.
The data path can only implement arithmetic operations involving one register and one immediate value.
Correct answer: A, B, C
Solution
Key idea: each ALU input is fed through its own multiplexer that can select either a register value or an immediate value. The ALU control selects the arithmetic operation and the result is written to RZ.
Two registers: By selecting the register output for the first multiplexer (RA) and the register output for the second multiplexer (RB), the ALU receives two register operands and can perform register-register arithmetic, producing a 32-bit result in RZ.
One register and one immediate: By selecting a register on one multiplexer and an immediate on the other, the ALU receives one register operand and one immediate operand and can perform register-immediate arithmetic.
Two immediates: Because each multiplexer has its own immediate input, both multiplexers can select their immediate inputs simultaneously. The ALU then receives two immediate operands and can compute an immediate-with-immediate result (even if such an instruction is rarely used in practice).
Conclusion: The data path supports arithmetic with two registers, one register and one immediate, and two immediates. The statement that the data path can only implement one register plus one immediate is incorrect.
Correct answer(s): The descriptions that the data path can implement arithmetic operations involving two registers, one register and one immediate value, and two immediate values are all supported by the shown connections.
The data path can implement arithmetic operations involving two registers.
The data path can implement arithmetic operations involving one register and one immediate value.
The data path can implement arithmetic operations involving two immediate values.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q35.GATE 2025
A regular language
\(L\)is accepted by a non-deterministic finite automaton (NFA) with\(n\)states. Which of the following statement(s) is/are FALSE?- A.
\(L\)may have an accepting NFA with\(< n\)states - B.
\(L\)may have an accepting DFA with\(< n\)states. - C.
There exists a DFA with
\(≤ 2^n\)states that accepts\(L\). - D.
Every DFA that accepts
\(L\)has\(> 2^n\)states.
Correct answer: D
Solution
Answer: Only the statement that every DFA accepting the language has more than 2^n states is false.
Statement about existence of an NFA with fewer than n states: Not universally false. Reason: The given NFA might not be minimal, so an equivalent NFA with fewer states can exist, though this is not guaranteed for every language.
Statement about existence of a DFA with fewer than n states: Not universally false. Reason: Some languages accepted by an n-state NFA may admit smaller DFAs, so this statement is possible but not guaranteed.
Statement that there exists a DFA with at most 2^n states: True. Reason: By the subset construction, every n-state NFA can be converted to an equivalent DFA whose states are subsets of the NFA states, giving at most 2^n DFA states.
Statement that every DFA accepting the language has more than 2^n states: False. Reason: The subset construction provides at least one DFA with at most 2^n states, so it cannot be true that every DFA requires more than 2^n states.
Conclusion: The only false statement is the claim that every DFA accepting the language has more than 2^n states.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q36.GATE 2025
Let 𝑆 be the set of all ternary strings defined over the alphabet
\(\{𝑎, 𝑏, 𝑐\}\). Consider all strings in\(S\)that contain at least one occurrence of two consecutive symbols, that is, “aa”, “bb” or “cc”. The number of such strings of length 5 that are possible is _______. (Answer in integer)Correct answer: 195
Solution
Answer: 195
Total number of ternary strings of length 5: 3^5 = 243
Count the strings that have no two consecutive symbols equal (i.e., avoid "aa", "bb", "cc") and subtract from the total:
Choose the first symbol: 3 choices.
For each of the remaining 4 positions, you must pick a symbol different from the previous one: 2 choices each, giving 2^4 = 16.
So the number of strings with no consecutive equal symbols is 3 * 2^4 = 48.
Therefore the number of length-5 strings that contain at least one occurrence of two consecutive identical symbols is 243 - 48 = 195.
- Q37.GATE 2025
Consider the given function
\(𝑓(𝑥)\).\(f(x) =\begin{cases} ax + b, & \text{for } x < 1 \\x^3 + x^2 + 1, & \text{for } x \geq 1\end{cases}\)If the function is differentiable everywhere, the value of 𝑏 must be ________. (rounded off to one decimal place)
Correct answer: -2
Solution
For f to be differentiable everywhere, it must be continuous at x = 1 and the left and right derivatives at x = 1 must be equal.
Continuity at x = 1: the left-hand value is a(1) + b = a + b, and the right-hand value is 1^3 + 1^2 + 1 = 3. Therefore a + b = 3, so b = 3 - a.
Differentiability at x = 1: the derivative from the left is a. The derivative from the right of x^3 + x^2 + 1 is 3x^2 + 2x, which at x = 1 equals 3 + 2 = 5. Thus a = 5.
Substitute a = 5 into b = 3 - a to get b = 3 - 5 = -2, which rounded to one decimal place is -2.0.
Answer: b = -2.0
A video solution is available for this question — log in and enroll to watch it.
- Q38.GATE 2025
A box contains 5 coins: 4 regular coins and 1 fake coin. When a regular coin is tossed, the probability 𝑃(ℎ𝑒𝑎𝑑) = 0.5 and for a fake coin, 𝑃(ℎ𝑒𝑎𝑑) = 1. You pick a coin at random and toss it twice, and get two heads. The probability that the coin you have chosen is the fake coin is _______. (rounded off to two decimal places)
Correct answer: 0.5
Solution
Answer: 0.50 (probability that the chosen coin is the fake coin, rounded to two decimal places)
Explanation using Bayes' theorem:
Prior probabilities: choosing the fake coin = 1/5; choosing a regular coin = 4/5.
Likelihoods of observing two heads: if the coin is fake, probability = 1; if the coin is regular, probability = 0.5 × 0.5 = 0.25.
Apply Bayes' theorem: posterior = (prior of fake × likelihood of two heads given fake) ÷ (total probability of two heads).
Compute values: numerator = (1/5) × 1 = 0.2. Denominator = (1/5) × 1 + (4/5) × 0.25 = 0.2 + 0.2 = 0.4. So posterior = 0.2 ÷ 0.4 = 0.5.
Rounded to two decimal places, the probability is 0.50.
Intuition: observing two heads makes the fake coin much more plausible because regular coins are relatively unlikely to produce two heads in a row.
A video solution is available for this question — log in and enroll to watch it.
- Q39.GATE 2025
The pseudocode of a function
\(fun()\)is given below:\(\begin{aligned}&\text{fun(int A[0, ... , n-1])} \\ &\text{\{} \\ &\quad \text{for } i = 0 \text{ to } n-2 \\ &\quad \quad \text{for } j = 0 \text{ to } n-i-2 \\ &\quad \quad \quad \text{if } (A[j] > A[j+1]) \\ &\quad \quad \quad \quad \text{then swap A[j] and A[j+1]} \\ &\text{\}}\end{aligned}\)Let
\(𝐴[0, … ,29]\)be an array storing 30 distinct integers in descending order. The number of swap operations that will be performed, if the function\(fun()\)is called with\(𝐴[0, … ,29]\)as argument, is __________. (Answer in integer)Correct answer: 435
Solution
Answer: 435
Explanation: The given code is the standard bubble sort that swaps adjacent out-of-order elements. The total number of swaps performed equals the initial number of inversions in the array.
For 30 distinct integers in descending order, every pair of indices (i, j) with i < j is an inversion.
Number of such pairs (inversions) = 30 choose 2 = 30 * 29 / 2 = 435
Each adjacent swap reduces the inversion count by exactly 1, so the total number of swaps equals the initial inversion count, which is 435.
A video solution is available for this question — log in and enroll to watch it.
- Q40.GATE 2025
#include <stdio.h>void foo(int *p, int x) {*p = x;}int main() {int *z;int a = 20, b = 25;z = &a;foo(z, b);printf("%d", a);return 0;}The output of the given C program is __________. (Answer in integer)
Correct answer: 25
Solution
Answer: 25
Explanation:
The pointer z is assigned the address of a, so z points to the variable a.
The function is called with p pointing to a and x equal to 25; inside the function, *p = x stores 25 into the location pointed to by p (which is a).
After the function returns, a has been updated to 25, so printf prints 25.
Note: There is no undefined behavior here because z is assigned the address of a before it is used.
A video solution is available for this question — log in and enroll to watch it.
- Q41.GATE 2025
The height of any rooted tree is defined as the maximum number of edges in the path from the root node to any leaf node.
Suppose a Min-Heap 𝑇 stores 32 keys. The height of 𝑇 is _____________. (Answer in integer)
Correct answer: 5
Solution
Answer: 5
Explanation: For a binary heap represented as a complete binary tree, the height h (maximum number of edges from the root to a leaf) satisfies 2^h <= n <= 2^(h+1) - 1, so h = floor(log2 n).
Compute floor(log2 32) = 5.
Alternative check: levels 0 through 4 contain 1 + 2 + 4 + 8 + 16 = 31 nodes, so the 32nd node is on level 5. Therefore the height (number of edges) is 5.
Final result: The height of the heap storing 32 keys is 5.
A video solution is available for this question — log in and enroll to watch it.
- Q42.GATE 2025
Consider a memory system with 1M bytes of main memory and 16K bytes of cache memory. Assume that the processor generates 20-bit memory address, and the cache block size is 16 bytes. If the cache uses direct mapping, how many bits will be required to store all the tag values? [Assume memory is byte addressable, 1K=210 , 1M=220 ]
- A.
6 × 210
- B.
8 × 210
- C.
212
- D.
214
Correct answer: A
Solution
Answer: 6 × 2^10 = 6144 bits
Reasoning:
Block offset: block size = 16 bytes → offset bits = log2(16) = 4 bits.
Number of cache lines: cache size = 16K = 2^14 bytes; lines = 2^14 / 2^4 = 2^10 = 1024 lines → index bits = 10.
Tag bits per line: address bits (20) - index bits (10) - offset bits (4) = 6 bits.
Total bits to store all tags: 6 bits per line × 1024 lines = 6 × 2^10 = 6144 bits.
Thus the choice '6 × 2^10' is the correct representation of the total tag storage.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q43.GATE 2025
A processor has 64 general-purpose registers and 50 distinct instruction types. An instruction is encoded in 32-bits. What is the maximum number of bits that can be used to store the immediate operand for the given instruction?
ADD R1, #25 // R1 = R1 + 25
- A.
16
- B.
20
- C.
22
- D.
24
Correct answer: B
Solution
Answer: 20 bits
Explanation:
Total instruction length = 32 bits.
Opcode bits = ceil(log2(50)) = 6 bits (since 2^5 = 32 < 50 ≤ 64 = 2^6).
Register bits = ceil(log2(64)) = 6 bits for each register identifier. This instruction uses one explicit register operand (the destination/source register), so use 6 bits.
Immediate bits = 32 - opcode bits - register bits = 32 - 6 - 6 = 20 bits.
Note: If an ISA required separate source and destination register fields for this instruction, that would consume more register bits and reduce the maximum immediate size. For the given assembly form which specifies a single register and an immediate, 20 bits is the maximum immediate field size.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q44.GATE 2025
Consider two relations describing
\(𝑡𝑒𝑎𝑚𝑠 \)and\(𝑝𝑙𝑎𝑦𝑒𝑟𝑠 \)in a sports league:•
\(𝑡𝑒𝑎𝑚𝑠(𝑡𝑖𝑑,𝑡𝑛𝑎𝑚𝑒): 𝑡𝑖𝑑, 𝑡𝑛𝑎𝑚e\)are team-id and team-name, respectively•
\(𝑝𝑙𝑎𝑦𝑒𝑟𝑠(𝑝𝑖𝑑, 𝑝𝑛𝑎𝑚𝑒,𝑡𝑖𝑑): 𝑝𝑖𝑑, 𝑝𝑛𝑎𝑚𝑒\), and\(𝑡𝑖𝑑\)denote player-id, playername and the team-id of the player, respectivelyWhich ONE of the following tuple relational calculus queries returns the name of the players who play for the team having 𝑡𝑛𝑎𝑚𝑒 as ′
\(𝑀𝐼\)′?Solution
Correct expression: { p.pname | p ∈ players ∧ ∃t (t ∈ teams ∧ p.tid = t.tid ∧ t.tname = 'MI') }
Why this is correct:
The main variable p ranges over the players relation, so p.pname refers to a valid player name.
The existentially quantified tuple t ranges over teams and provides the team context to test.
The equality p.tid = t.tid links a player to their team, ensuring we only consider the player's own team.
The condition t.tname = 'MI' filters to the specific team named 'MI'. Combined, these return exactly the players who play for 'MI'.
Why the other expressions are wrong:
Expressions that bind the main variable to the teams relation and then try to return p.pname are invalid because team tuples do not have a player-name attribute.
Expressions that omit the equality p.tid = t.tid fail to link players to teams; such a query would return every player's name whenever any team named 'MI' exists, which is not the intended result.
Swapping the roles of the quantified relation (making the existential range over players while treating the main variable as a team) also mismatches attributes and produces incorrect or meaningless conditions.
Summary: The correct query binds the result variable to players, uses an existential team tuple to find a matching team by id, and filters that team by name 'MI'.
A video solution is available for this question — log in and enroll to watch it.
- Q45.GATE 2025
A packet with the destination IP address 145.36.109.70 arrives at a router whose routing table is shown. Which interface will the packet be forwarded to?

- A.
E3
- B.
E1
- C.
E2
- D.
E5
Correct answer: A
Solution
Final answer: E3
Reasoning: Use longest-prefix match (the most specific route). Check which table entries include 145.36.109.70.
145.36.255.0/24: covers 145.36.255.0–145.36.255.255 — does not include 145.36.109.70.
145.36.64.0/18: mask 255.255.192.0, covers 145.36.64.0–145.36.127.255 — this range includes 145.36.109.70.
145.36.128.0/17: covers 145.36.128.0–145.36.255.255 — does not include 145.36.109.70.
145.36.0.0/16: covers 145.36.0.0–145.36.255.255 — includes the address but is less specific than the /18 entry.
Conclusion: The most specific matching route is 145.36.64.0/18, so the router forwards the packet to E3.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q46.GATE 2025
Let
(A)be a 2 × 2 matrix as given.
What are the eigenvalues of the matrix
𝐴^(13)?- A.
(1, −1) - B.
2(2)^(1/2) and -2(2)^(1/2)
- C.
4(2)^(1/2) and -4(2)^(1/2)
- D.
64(2)^(1/2) and -64(2)^(1/2)
Correct answer: D
Solution
Solution: Find the eigenvalues of A and then raise them to the 13th power.
Compute the characteristic polynomial: det(A − λI) = (1 − λ)(−1 − λ) − 1 = λ^2 − 2.
Thus λ^2 = 2, so the eigenvalues of A are sqrt(2) and −sqrt(2).
For any integer k, the eigenvalues of A^k are the eigenvalues of A raised to the k-th power.
(sqrt(2))^13 = 2^(13/2) = 2^6 * sqrt(2) = 64 sqrt(2).
(-sqrt(2))^13 = - (sqrt(2))^13 = -64 sqrt(2).
Therefore the eigenvalues of A^13 are 64 sqrt(2) and -64 sqrt(2).
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q47.GATE 2025
Consider the following four variable Boolean function in sum-of-product form
\(𝐹(𝑏_3, 𝑏_2, 𝑏_1, 𝑏_0) = ∑(0, 2, 4, 8, 10, 11, 12).\)where the value of the function is computed by considering
\(𝑏_3𝑏_2𝑏_1𝑏_0\)as a 4-bit binary number, where\(𝑏_3\)denotes the most significant bit and\(𝑏_0\)denotes the least significant bit. Note that there are no don’t care terms. Which ONE of the following options is the CORRECT minimized Boolean expression for\(F\)?- A.
\(\bar{b}_1 \bar{b}_0 + \bar{b}_2 \bar{b}_0 + b_1 \bar{b}_2 b_3 \) - B.
\(\bar{b}_1 \bar{b}_0 + \bar{b}_2 \bar{b}_0 \) - C.
\(\bar{b}_2 \bar{b}_0 + b_1 b_2 b_3 \) - D.
\(\bar{b}_0 \bar{b}_2 + \bar{b}_3\)
Correct answer: A
Solution
Minimized expression: b1' b0' + b2' b0' + b1 b3 b2'
Derivation (grouping by covered minterms):
b1' b0' covers minterms 0 (0000), 4 (0100), 8 (1000), and 12 (1100).
b2' b0' covers minterms 0 (0000), 2 (0010), 8 (1000), and 10 (1010).
b1 b3 b2' covers minterms 10 (1010) and 11 (1011); minterm 10 is already covered, and this term adds the required minterm 11.
Combine coverage:
Union of covered minterms = {0, 2, 4, 8, 10, 11, 12}, exactly the given set.
No extra minterms are covered, so the expression matches the function.
Therefore the minimized Boolean expression is b1' b0' + b2' b0' + b1 b3 b2'.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q48.GATE 2025
Let
\(𝐺(𝑉, 𝐸)\)be an undirected and unweighted graph with 100 vertices. Let\(𝑑(𝑢, 𝑣)\)denote the number of edges in a shortest path between vertices\(u\)and\(v\)in\(V\). Let the maximum value of\(𝑑(𝑢, 𝑣), 𝑢, 𝑣 ∈ 𝑉\)such that\(𝑢 ≠ 𝑣\), be 30. Let\(T\)be any breadthfirst-search tree of\(G\). Which ONE of the given options is CORRECT for every such graph\(G\)?- A.
The height of
\(T\)is exactly 15. - B.
The height of
\(T\)is exactly 30. - C.
The height of
\(T\)is at least 15. - D.
The height of
\(T\)is at least 30.
Correct answer: C
Solution
Given: the graph has diameter 30, i.e. the maximum shortest-path distance between any two vertices is 30.
Key facts:
The height of a breadth-first-search (BFS) tree rooted at a vertex equals that vertex's eccentricity, i.e. the maximum distance from that root to any vertex.
The radius of the graph is the minimum eccentricity over all vertices.
A standard inequality relates diameter and radius: diameter ≤ 2 × radius. Rearranged, this gives radius ≥ ceil(diameter/2).
Apply these facts with diameter = 30:
radius ≥ ceil(30/2) = 15.
Every vertex's eccentricity is at least the radius, so every vertex's eccentricity ≥ 15.
Therefore, the height of any BFS tree (being the eccentricity of its root) is at least 15.
Why the other exact/strong statements fail:
The height need not be exactly 15: if the BFS root is chosen at a central vertex the height can be 15, but other roots can give larger heights.
The height need not be exactly 30 or at least 30: if the root is chosen near the center the height can be 15, so 30 is not a guaranteed lower bound.
Conclusion: The only statement that is always true for every BFS tree of every graph with diameter 30 is that the height is at least 15.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q49.GATE 2025
Consider the following two languages over the alphabet
\(\{𝑎, 𝑏\}\):\(L_1 = \{ \alpha \beta \alpha \mid \alpha \in \{a, b\}^+ \text{ AND } \beta \in \{a, b\}^+ \} \\ L_2 = \{ \alpha \beta \alpha \mid \alpha \in \{a\}^+ \text{ AND } \beta \in \{a, b\}^+ \}\)Which ONE of the following statements is CORRECT ?
- A.
Both
\(L_1\)and\(L_2\)are regular languages. - B.
\(L_1\)is a regular language but\(L_2\)is not a regular language. - C.
\(L_1\)is not a regular language but\(L_2\)is a regular language. - D.
Neither
\(L_1\)nor\(L_2\)is a regular language.
Correct answer: C
Solution
Answer: L1 is a not regular language and L2 is a regular language.
L1 is not regular as we have to match starting and ending part(not alphabet) of string.
NOTE: this is not your typical "starting and ending with same symbol" string, if it is, try to match this string using DFA/NFA - "abbaab"L2 is regular. here, we have to only check "starting and ending with a" strings which is regular
Analysis of L₁The language L₁ consists of all strings that can be written as αβα, where both α and β are nonempty strings over a, b. Hence, the prefix and suffix must be identical and nonempty.
To verify this property, a finite automaton would need to “remember” an arbitrary-length prefix α to compare it with the suffix, which requires unbounded memory. This strongly suggests non-regularity.
The language L₂ can be described by the regular expressiona(a+b)+a.
This clearly defines a regular language, since the class of regular languages is closed under concatenation and the Kleene plus operation.
A simple DFA can recognize L₂ by:
Checking that the first symbol is a,
Reading one or more middle symbols,
Accepting only if the final symbol is a.
Thus, L₂ is regular.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q50.GATE 2025
Consider the following two languages over the alphabet
\(\{𝑎, 𝑏, 𝑐\}\), where 𝑚 and 𝑛 are natural numbers.\(L_1 = \{ a^m b^m c^{m+n} \mid m, n \geq 1 \} \\ L_2 = \{ a^m b^n c^{m+n} \mid m, n \geq 1 \} \)Which ONE of the following statements is CORRECT?
- A.
Both
\(𝐿_1\)and\(𝐿_2\)are context-free languages. - B.
\(𝐿_1\)is a context-free language but\(𝐿_2\)is not a context-free language. - C.
\(𝐿_1\)is not a context-free language but\(𝐿_2\)is a context-free language. - D.
Neither
\(𝐿_1\)nor\(𝐿_2\)are context-free languages.
Correct answer: C
Solution
Answer: The first language is not context-free, and the second language is context-free.
Reason (second language is context-free):
A context-free grammar that generates the language a^m b^n c^{m+n} (with m,n ≥ 1) is:
S -> a S c | a B c
B -> b B c | b c
Each application of the first production adds one a at the front and one c at the end (counting toward the m part); when we stop producing a's we switch to B which produces n b's and n c's. Overall this yields a^m b^n c^{m+n} with m,n ≥ 1, so the language is context-free.
Reason (first language is not context-free):
Use the pumping lemma for context-free languages. Let p be the pumping length. Consider the string s = a^p b^p c^{p+1}, which belongs to the language a^m b^m c^{m+n} (take m = p and n = 1).
By the pumping lemma, s = u v w x y with |vwx| ≤ p and |vx| ≥ 1, and for all i ≥ 0 the string u v^i w x^i y must be in the language if it were context-free.
Because |vwx| ≤ p, the substring vwx lies entirely within one of these zones: the block of a's, the block of b's, or the block of the first p+1 c's, or it crosses a single adjacent boundary. In every case pumping with i = 0 changes the counts in a way that breaks the required relation between numbers of a's and b's or makes the c-count invalid (for example, if vwx lies inside a's, removing vx reduces the number of a's but leaves b's unchanged, so the numbers of a's and b's are no longer equal; if vwx lies inside the c's, removing vx can make the number of c's ≤ m which violates the requirement that c count = m+n with n ≥ 1). Thus for i = 0 the pumped string is not in the language, a contradiction.
Hence the first language cannot satisfy the pumping lemma for CFLs and is not context-free.
Conclusion: The correct statement is that the first language is not context-free while the second language is context-free.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q51.GATE 2025
Which of the following statement(s) is/are TRUE while computing
\(First \)and\(Follow \)during top down parsing by a compiler?- A.
For a production
\( 𝐴 → 𝜖, 𝜖\)will be added to\(𝐹𝑖𝑟𝑠𝑡(𝐴)\). - B.
If there is any input right end marker, it will be added to
\(𝐹𝑖𝑟𝑠𝑡(𝑆)\), where\(S\)is the start symbol. - C.
For a production
\(𝐴 → 𝜖, 𝜖\)will be added to\(𝐹𝑜𝑙𝑙𝑜𝑤(𝐴)\). - D.
If there is any input right end marker, it will be added to
\(𝐹𝑜𝑙𝑙𝑜𝑤(𝑆)\), where\(S\)is the start symbol.
Correct answer: A, D
Solution
Correct statements:
If a nonterminal has a production that derives the empty string (A → ε), then ε is included in First(A). Explanation: First(A) lists the terminals that can begin strings derived from A and also includes ε when A can derive the empty string.
The input right end marker (commonly $) is added to Follow(S) for the start symbol S. Explanation: Follow(S) contains symbols that can appear immediately after S; since nothing follows the start symbol in a complete sentential form, the end marker belongs to Follow(S).
Why the other statements are false:
The input right end marker is not added to First(S). First sets contain possible starting terminals (and possibly ε), while the end marker indicates the end of input and is not a starting terminal.
ε is not added to Follow(A). Follow sets list terminals (and possibly the end marker) that can appear immediately after A; ε is not such a terminal and therefore does not belong in Follow.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q52.GATE 2025
Consider a relational schema
\(𝑡𝑒𝑎𝑚(𝑛𝑎𝑚𝑒, 𝑐𝑖𝑡𝑦, 𝑜𝑤𝑛𝑒𝑟)\), with functional dependencies\(\{𝑛𝑎𝑚𝑒 → 𝑐𝑖𝑡𝑦, 𝑛𝑎𝑚𝑒 → 𝑜𝑤𝑛𝑒𝑟\}\).The relation
\(𝑡𝑒𝑎𝑚\)is decomposed into two relations,\(𝑡1(𝑛𝑎𝑚𝑒, 𝑐𝑖𝑡𝑦)\)and\(𝑡2(𝑛𝑎𝑚𝑒, 𝑜𝑤𝑛𝑒𝑟)\). Which of the following statement(s) is/are TRUE?- A.
The relation
\(𝑡𝑒𝑎𝑚\)is NOT in BCNF. - B.
The relations
\(t1\)and\(t2\)are in BCNF. - C.
The decomposition constitutes a lossless join.
- D.
The relation
\(𝑡𝑒𝑎𝑚 \)is NOT in 3NF.
Correct answer: B, C
Solution
Identify the candidate key: name determines both city and owner, so name is a candidate key for the relation.
BCNF for the original relation: Every non‑trivial functional dependency (name -> city, name -> owner) has the left side equal to a key, so the original relation is in BCNF.
t1 (name, city): name -> city, so name is the key for t1; therefore t1 is in BCNF.
t2 (name, owner): name -> owner, so name is the key for t2; therefore t2 is in BCNF.
Lossless join: The common attribute between the decomposed relations is name, which is a key for the relations. Since the common attribute is a key in at least one relation (here in both), the decomposition is lossless.
3NF: Because the relation is in BCNF, it also satisfies 3NF.
Conclusion: The statements that the decomposed relations are in BCNF and that the decomposition is lossless are true. The statements claiming the original relation is not in BCNF or not in 3NF are false.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q53.GATE 2025
Which of the following predicate logic formulae/formula is/are CORRECT representation(s) of the statement: “Everyone has exactly one mother”?
The meanings of the predicates used are:
•
\(𝑚𝑜𝑡ℎ𝑒𝑟(𝑦, 𝑥): 𝑦\)is the mother of\(x\)•
\(𝑛𝑜𝑡𝑒𝑞(𝑥, 𝑦): 𝑥\)and\(y\)are not equal- A.
\(∀𝑥∃𝑦∃𝑧(𝑚𝑜𝑡ℎ𝑒𝑟(𝑦, 𝑥) ∧ ¬𝑚𝑜𝑡ℎ𝑒𝑟(𝑧, 𝑥))\) - B.
\(∀𝑥∃𝑦[𝑚𝑜𝑡ℎ𝑒𝑟(𝑦, 𝑥) ∧ ∀𝑧(𝑛𝑜𝑡𝑒𝑞(𝑧, 𝑦) → ¬𝑚𝑜𝑡ℎ𝑒𝑟(𝑧, 𝑥))]\) - C.
\(∀𝑥∀𝑦[𝑚𝑜𝑡ℎ𝑒𝑟(𝑦, 𝑥) → ∃𝑧(𝑚𝑜𝑡ℎ𝑒𝑟(𝑧, 𝑥) ∧ ¬𝑛𝑜𝑡𝑒𝑞(𝑧, 𝑦))]\) - D.
\(∀𝑥∃𝑦[𝑚𝑜𝑡ℎ𝑒𝑟(𝑦, 𝑥) ∧ ¬∃𝑧(𝑛𝑜𝑡𝑒𝑞(𝑧, 𝑦) ∧ 𝑚𝑜𝑡ℎ𝑒𝑟(𝑧, 𝑥))]\)
Correct answer: B, D
Solution
Correct formalizations:
∀x ∃y [ mother(y,x) ∧ ∀z ( mother(z,x) → ¬noteq(z,y) ) ]
∀x ∃y [ mother(y,x) ∧ ¬∃z ( noteq(z,y) ∧ mother(z,x) ) ]
Explanation:
Existence: The ∀x ∃y mother(y,x) part ensures every person x has at least one mother.
Uniqueness (first form): ∀z (mother(z,x) → ¬noteq(z,y)) means any mother z of x must not be different from y, i.e. z = y.
Uniqueness (second form): ¬∃z (noteq(z,y) ∧ mother(z,x)) states there is no different individual z who is also a mother of x.
Why the other given formulas fail:
The formula ∀x ∃y ∃z (mother(y,x) ∧ ¬mother(z,x)) only requires there be some non-mother for each x in addition to at least one mother; it does not rule out multiple distinct mothers, so it does not express "exactly one."
The formula ∀x ∀y [mother(y,x) → ∃z (mother(z,x) ∧ ¬noteq(z,y))] is essentially tautological about any given mother y (it asserts there is a mother equal to y) and does not guarantee every x has a mother nor that there is only one mother, so it fails to capture the intended meaning.
- A.
- Q54.GATE 2025
\(𝐴 = \{0, 1, 2, 3, … \}\)is the set of non-negative integers. Let\(F\)be the set of functions from\(A\)to itself. For any two functions,\(𝑓_1, 𝑓_2 ∈ Ϝ\), we define\((𝑓_1⨀𝑓_2)(𝑛) = 𝑓_1(𝑛) + 𝑓_2(𝑛)\)for every number
\(n\)in\(A\). Which of the following is/are CORRECT about the mathematical structure\((Ϝ, ⨀)\)?- A.
\((Ϝ, ⨀)\)is an Abelian group. - B.
\((Ϝ, ⨀)\)is an Abelian monoid. - C.
\((Ϝ, ⨀)\)is a non-Abelian group. - D.
\((Ϝ, ⨀)\)is a non-Abelian monoid.
Correct answer: B
Solution
Key facts: The operation is pointwise addition: (f1 ⨀ f2)(n) = f1(n) + f2(n) for each n in A (the set of non-negative integers).
Closure: For any two functions f1,f2 in F, f1(n)+f2(n) is a non-negative integer for every n, so f1 ⨀ f2 is in F.
Associativity: Integer addition is associative, so pointwise addition of functions is associative.
Identity element: The zero function 0 defined by 0(n)=0 for all n is the identity because f ⨀ 0 = f for every f in F.
Commutativity: Integer addition is commutative, hence pointwise addition is commutative.
Lack of inverses in general: For a function f with f(n)>0 for some n, there is no g in F with f(n)+g(n)=0 because g(n) would have to be negative. Example: the constant-1 function has no inverse in F.
Conclusion: The structure (F, ⨀) satisfies closure, associativity, identity, and commutativity, so it is an Abelian (commutative) monoid. It is not a group because most elements do not have additive inverses in the set of non-negative integers.
Assessment of the given statements:
The statement that the structure is an Abelian monoid is correct.
The statements that the structure is an Abelian group, a non-Abelian group, or a non-Abelian monoid are incorrect (it is not a group, and it is commutative, so it cannot be non-Abelian).
- A.
- Q55.GATE 2025
Consider the following deterministic finite automaton (DFA) defined over the alphabet,
\(Σ = \{𝑎, 𝑏\}\). Identify which of the following language(s) is/are accepted by the given DFA.
- A.
The set of all strings containing an even number of
\(𝑏\)’s. - B.
The set of all strings containing the pattern
\(𝑏𝑎𝑏\). - C.
The set of all strings ending with the pattern
\(𝑏𝑎𝑏\). - D.
The set of all strings not containing the pattern
\(𝑎𝑏𝑎\).
Correct answer: C
Solution
Final answer: The DFA accepts exactly the set of all strings that contain an even number of b's.
Reasoning: the automaton effectively tracks the parity of the number of b's seen so far.
Start/accepting state = even number of b's observed so far (including zero).
Reading an a does not change parity: transitions on a stay within the same parity class, so a's do not affect acceptance.
Reading a b toggles parity: each b moves the machine between the even and odd parity states. Therefore acceptance depends solely on whether the total number of b's is even.
Examples (to build intuition):
Accepted: the empty string (0 b's), "aa" (0 b's), "bb" (2 b's), "abaabb" (2 b's).
Rejected: "b" (1 b), "ab" (1 b), "bba" (1 b), "bbab" (3 b's).
Why the other described languages do not match the DFA:
The property "contains the substring 'bab'": not equivalent. Counterexample: "bbab" contains 'bab' but has three b's and is rejected.
The property "ends with 'bab'": not equivalent. Counterexample: "bbab" ends with 'bab' but is rejected since it has an odd number of b's.
The property "does not contain 'aba'": not equivalent. Counterexample: "b" does not contain 'aba' but is rejected because it has an odd number of b's.
Conclusion: The DFA accepts exactly those strings over {a, b} whose total number of b's is even.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q56.GATE 2025
Refer to the given 3-address code sequence. This code sequence is split into basic blocks. The number of basic blocks is ________. (Answer in integer)
\(\begin{aligned} &1001: \quad i = 1 \\ &1002: \quad j = 1 \\ &1003: \quad t1 = 10 \cdot i \\ &1004: \quad t2 = t1 + j \\ &1005: \quad t3 = 8 \cdot t2 \\ &1006: \quad t4 = t3 - 88 \\ &1007: \quad a[t4] = 0.0 \\ &1008: \quad j = j + 1 \\ &1009: \quad \text{if } j \leq 10 \text{ goto } 1003 \\ &1010: \quad i = i + 1 \\ &1011: \quad \text{if } i \leq 10 \text{ goto } 1002 \\ &1012: \quad i = 1 \\ &1013: \quad t5 = i - 1 \\ &1014: \quad t6 = 88 \cdot t5 \\ &1015: \quad a[t6] = 1.0 \\ &1016: \quad i = i + 1 \\ &1017: \quad \text{if } i \leq 10 \text{ goto } 1013 \end{aligned} \)Correct answer: 6
Solution
Answer: 6
Explanation:
Step 1: Find leaders. A leader is the first instruction, any target of a jump, and any instruction that immediately follows a conditional or unconditional jump.
Apply to the code: leaders are 1001 (first instruction), 1003 (target of the jump at 1009), 1002 (target of the jump at 1011), 1010 (instruction after the conditional at 1009), 1012 (instruction after the conditional at 1011), and 1013 (target of the jump at 1017).
Step 2: Form basic blocks by grouping each leader with following instructions up to (but not including) the next leader.
The basic blocks are:
Block 1: instruction 1001
Block 2: instruction 1002
Block 3: instructions 1003–1009
Block 4: instructions 1010–1011
Block 5: instruction 1012
Block 6: instructions 1013–1017
Step 3: Count the blocks. There are 6 basic blocks in total.
A video solution is available for this question — log in and enroll to watch it.
- Q57.GATE 2025
A computer has a memory hierarchy consisting of two-level cache (L1 and L2) and a main memory. If the processor needs to access data from memory, it first looks into L1 cache. If the data is not found in L1 cache, it goes to L2 cache. If it fails to get the data from L2 cache, it goes to main memory, where the data is definitely available. Hit rates and access times of various memory units are shown in the figure. The average memory access time in nanoseconds (ns) is ________. (rounded off to two decimal places)

Correct answer: 11.85
Solution
Answer: 11.85 ns (rounded to two decimals)
Explanation and steps:
L1 cache: hit rate = 95% (0.95), access time = 10 ns. On an L1 miss (5% of accesses) the processor goes to L2.
L2 cache: conditional hit rate given an L1 miss = 85% (0.85), access time = 20 ns (this value already includes the L1 miss penalty). On an L2 miss (15% of L1 misses) the processor goes to main memory.
Main memory: access time = 200 ns (this includes the penalties from L1 and L2 misses).
Compute the average memory access time (AMAT):
AMAT = (probability of L1 hit) × (L1 time) + (probability of L1 miss) × [ (probability of L2 hit given L1 miss) × (L2 time) + (probability of L2 miss given L1 miss) × (main memory time) ]
AMAT = 0.95 × 10 + 0.05 × [0.85 × 20 + 0.15 × 200]
Calculate inner bracket: 0.85 × 20 = 17; 0.15 × 200 = 30; sum = 47
So AMAT = 0.95 × 10 + 0.05 × 47 = 9.5 + 2.35 = 11.85 ns
Final answer: 11.85 ns
A video solution is available for this question — log in and enroll to watch it.
- Q58.GATE 2025
Consider the following database tables of a sports league.
\( \begin{array}{l l} \textbf{player}(\text{pid}, \text{pname}, \text{age}) & \textbf{team}(\text{tid}, \text{tname}, \text{city}, \text{cid}) \\ \textbf{coach}(\text{cid}, \text{cname}) & \textbf{members}(\text{pid}, \text{tid}) \end{array} \)An instance of the table and an SQL query are given.

\(\begin{aligned} &\text{SELECT } \text{MIN}(P.\text{age}) \\ &\text{FROM } \textbf{player} \ P \\ &\text{WHERE } P.\text{pid} \text{ IN } ( \\ &\quad \text{SELECT } M.\text{pid} \\ &\quad \text{FROM } \textbf{team} \ T, \textbf{coach} \ C, \textbf{members} \ M \\ &\quad \text{WHERE } C.\text{cname} = 'Mark' \\ &\quad \text{AND } T.\text{cid} = C.\text{cid} \\ &\quad \text{AND } M.\text{tid} = T.\text{tid} \ ) \end{aligned} \)The value returned by the given SQL query is ______ . (Answer in integer)
Correct answer: 26
Solution
Key idea: find the players who are members of teams coached by Mark, then take the minimum of their ages.
Find the coach record for the name Mark: Mark has cid = 102.
Find teams with cid = 102: that is the team with tid = 10.
Find members with tid = 10: the member pids are 1 and 3.
Look up ages for pid 1 and pid 3: ages are 31 and 26. The minimum age is 26.
Answer: 26
A video solution is available for this question — log in and enroll to watch it.
- Q59.GATE 2025
Suppose a 5-bit message is transmitted from a source to a destination through a noisy channel. The probability that a bit of the message gets flipped during transmission is 0.01. Flipping of each bit is independent of one another. The probability that the message is delivered error-free to the destination is ______ . (rounded off to three decimal places)
Correct answer: 0.949 to 0.952
Solution
Each bit has:
Probability of flipping (error) = 0.01
Probability of not flipping (correct) = 0.99
Message length = 5 bits
Bits flip independently.To receive the entire 5-bit message error-free, all 5 bits must be correct:
P(no error)=(0.99)5
Compute:
0.995=0.9510
Rounded to three decimal places:
0.951
A video solution is available for this question — log in and enroll to watch it.
- Q60.GATE 2025
Suppose a message of size 15000 bytes is transmitted from a source to a destination using IPv4 protocol via two routers as shown in the figure. Each router has a defined maximum transmission unit (MTU) as shown in the figure, including IP header. The number of fragments that will be delivered to the destination is ________ . (Answer in integer)

Correct answer: 7
Solution
Answer: 7 fragments.
Explanation and steps:
Assume the IPv4 header is 20 bytes. The data to be carried by IP is therefore 15000 - 20 = 14980 bytes (if the 15000 was the entire datagram) — the calculation below is the same if you treat 15000 as data because the fragmentation arithmetic yields the same final count.
At Router-1 the MTU is 5000 bytes, so the maximum payload per fragment is 5000 - 20 = 4980 bytes. Because fragment offsets are in 8-byte units, each fragment's payload must be a multiple of 8, so use 4976 bytes per fragment.
Split 14980 bytes of data into 4976-byte chunks: 4976 * 3 = 14928, leaving a final piece of 14980 - 14928 = 52 bytes. So after Router-1 we have three fragments carrying 4976 bytes each and one fragment carrying 52 bytes (total 4 fragments).
At Router-2 the MTU is 3000, so maximum payload per fragment is 3000 - 20 = 2980 bytes. Adjusting to an 8-byte multiple gives 2976 bytes per fragment.
Each 4976-byte payload from Router-1 must be split into 2976 + 2000 bytes (4976 = 2976 + 2000). The 2000-byte piece is already a multiple of 8, so no further splitting is needed. Thus every large fragment from Router-1 becomes two fragments at Router-2.
The small 52-byte fragment from Router-1 fits within Router-2's MTU and is not fragmented further.
Total fragments delivered to the destination = (3 large fragments × 2 after second fragmentation) + (1 small fragment) = 6 + 1 = 7.
A video solution is available for this question — log in and enroll to watch it.
- Q61.GATE 2025
Consider a probability distribution given by the density function
\(𝑃(𝑥)\).\(P(x) = \begin{cases} Cx^2, & \text{for } 1 \leq x \leq 4 \\ 0, & \text{for } x < 1 \text{ or } x > 4 \end{cases} \)The probability that
\(x\)lies between 2 and 3, i.e.,\(𝑃(2 ≤ 𝑥 ≤ 3)\)is __________. (rounded off to three decimal places)Correct answer: 0.302
Solution
Normalize the density to find the constant C:
Integrate the density over its support and set the total probability to 1:
Compute ∫ from 1 to 4 of C x² dx = 1. This gives C · [x³/3]₁⁴ = 1.
Evaluate the bracket: x³/3 from 1 to 4 = (64/3) − (1/3) = 63/3 = 21. So C · 21 = 1, hence C = 1/21.
Now compute the probability that x lies between 2 and 3:
P(2 ≤ x ≤ 3) = ∫₂³ (1/21) x² dx = (1/21) · [x³/3]₂³.
Evaluate: [x³/3]₂³ = (27/3) − (8/3) = 19/3. So the probability is (1/21) · (19/3) = 19/63.
Numeric value rounded to three decimal places:
19/63 ≈ 0.302
A video solution is available for this question — log in and enroll to watch it.
- Q62.GATE 2025
Consider a finite state machine (FSM) with one input
\(X\)and one output\(𝑓\), represented by the given state transition table. The minimum number of states required to realize this FSM is ________. (Answer in integer)
Correct answer: 5
Solution
Final answer: 5 states
Explanation:
Recognize the machine type: outputs depend on current state and input, so this is a Mealy machine. Equivalent states must have identical outputs for each input and their next states must also be equivalent.
Initial partition by output pairs (output for X=0, X=1):
States with outputs (0,0): A, B, C, E. States with outputs (1,0): D, H. State with outputs (1,1): F. State with outputs (0,1): G.
Compute next-state transitions (from the table): A: X=0→F, X=1→B; B: X=0→D, X=1→C; C: X=0→F, X=1→E; D: X=0→G, X=1→A; E: X=0→D, X=1→C; F: X=0→F, X=1→B; G: X=0→G, X=1→H; H: X=0→G, X=1→A.
Refine the partition using these transitions (map next states to the current groups). The group {A,B,C,E} splits because A and C transition to F then to states in the (0,0) group differently than B and E. After refinement the groups become: {A, C}, {B, E}, {D, H}, {F}, {G}.
Check for further splits: within each refined group all states have identical output behavior and next-state mappings (relative to the refined groups), so no further splitting is needed.
Therefore the minimal number of states required to realize this Mealy FSM is 5.
A video solution is available for this question — log in and enroll to watch it.
- Q63.GATE 2025
Consider the given sequential circuit designed using D-Flip-flops. The circuit is initialized with some value (initial state). The number of distinct states the circuit will go through before returning back to the initial state is _________ . (Answer in integer)

Correct answer: 7
Solution
Key idea: follow the state of the four flip-flops through successive clock cycles using the feedback connections shown in the diagram. Each clock updates Q0..Q3 according to the wires: each stage receives (from the previous stage) either the direct or complemented output as drawn, and the rightmost output is fed back to the leftmost input.
Trace one full cycle (starting from an example initial state) to count distinct states before the pattern repeats. For example, starting from the state 1000 (Q0=1, Q1=0, Q2=0, Q3=0) the circuit evolves as follows:
1000 → after 1 clock → 0100
0100 → after 2 clocks → 0010
0010 → after 3 clocks → 0001
0001 → after 4 clocks → 1110
1110 → after 5 clocks → 0111
0111 → after 6 clocks → 1011
1011 → after 7 clocks → 1000 (back to the initial state)
Since we returned to the initial state after 7 distinct states, the circuit cycles through 7 distinct states before returning to the initial state. Therefore the answer is 7.
A video solution is available for this question — log in and enroll to watch it.
- Q64.GATE 2025
#include <stdio.h>
int foo(int S[], int size) {
if(size == 0) return 0;
if(size == 1) return 1;
if(S[0] != S[1]) return 1 + foo(S + 1, size - 1);
return foo(S + 1, size - 1);
}
int main() {
int A[] = {0, 1, 2, 2, 2, 0, 0, 1, 1};
printf("%d", foo(A, 9));
return 0;
}
The value printed by the given C program is _______ . (Answer in integer)
Correct answer: 5
Solution
Answer: 5
Reasoning:
The function returns the number of groups of consecutive equal elements in the array. For size 0 it returns 0, for size 1 it returns 1 (one group). For larger sizes, it compares the first two elements: if they differ it counts a new group (adds 1) and recurses on the rest; if they are equal it continues without incrementing.
Apply this to the array {0, 1, 2, 2, 2, 0, 0, 1, 1}: it splits into the consecutive groups 0 | 1 | 2 2 2 | 0 0 | 1 1, which are 5 groups in total.
Group 1: 0
Group 2: 1
Group 3: 2, 2, 2
Group 4: 0, 0
Group 5: 1, 1
Therefore the program prints 5.
A video solution is available for this question — log in and enroll to watch it.
- Q65.GATE 2025
Let
\(LIST \)be a datatype for an implementation of linked list defined as follows:\(\begin{array}{l} \text{typedef struct list \{} \\ \quad \text{int data;} \\ \quad \text{struct list *next;} \\ \text{\} LIST;} \end{array} \)Suppose a program has created two linked lists, L1 and L2, whose contents are given in the figure below (code for creating L1 and L2 is not provided here). L1 contains 9 nodes, and L2 contains 7 nodes. Consider the following C program segment that modifies the list L1. The number of nodes that will be there in L1 after the execution of the code segment is ________ . (Answer in integer)

\(\begin{array}{l} \text{int find (int query, LIST *list) \{} \\ \quad \text{while (list != NULL) \{} \\ \quad\quad \text{if (list->data == query) return 1;} \\ \quad\quad \text{list = list->next;} \\ \quad \text{\}} \\ \quad \text{return 0;} \\ \text{\}} \\[10pt] \text{int main () \{} \\ \quad \text{... ... ...} \\ \quad \text{ptr1 = L1; ptr2 = L2;} \\ \quad \text{while (ptr1->next != NULL) \{} \\ \quad\quad \text{query = ptr1->next->data;} \\ \quad\quad \text{if (find (query, L2))} \\ \quad\quad\quad \text{ptr1->next = ptr1->next->next;} \\ \quad\quad \text{else ptr1 = ptr1->next;} \\ \quad \text{\}} \\ \quad \text{... ... ...} \\ \quad \text{return 0;} \\ \text{\}} \end{array} \)Correct answer: 5
Solution
Final answer: 5 nodes
Explanation: The loop inspects the next node of the current pointer and removes that next node if its value appears anywhere in the second list. Simulating the loop shows which nodes are skipped (removed) and which remain.
Start: L1 = 1 -> 7 -> 12 -> 3 -> 9 -> 5 -> 11 -> 15 -> 8. L2 contains values {1, 11, 6, 9, 15, 12, 4}.
Check the node after 1 (value 7): 7 is not in L2, so move ptr1 to 7.
Check the node after 7 (value 12): 12 is in L2, so remove 12. List becomes 1 -> 7 -> 3 -> 9 -> 5 -> 11 -> 15 -> 8. ptr1 stays at 7.
Check the node after 7 (now value 3): 3 is not in L2, so move ptr1 to 3.
Check the node after 3 (value 9): 9 is in L2, so remove 9. List becomes 1 -> 7 -> 3 -> 5 -> 11 -> 15 -> 8. ptr1 stays at 3.
Check the node after 3 (now value 5): 5 is not in L2, so move ptr1 to 5.
Check the node after 5 (value 11): 11 is in L2, so remove 11. List becomes 1 -> 7 -> 3 -> 5 -> 15 -> 8. ptr1 stays at 5.
Check the node after 5 (value 15): 15 is in L2, so remove 15. List becomes 1 -> 7 -> 3 -> 5 -> 8. ptr1 stays at 5.
Check the node after 5 (value 8): 8 is not in L2, so move ptr1 to 8. Now ptr1->next is NULL and the loop ends.
Final remaining L1: 1 -> 7 -> 3 -> 5 -> 8 (5 nodes).
A video solution is available for this question — log in and enroll to watch it.
- Q66.GATE 2025
Consider the following C program:
#include <stdio.h>
int gate (int n) {
int d, t, newnum, turn;
newnum = turn = 0; t=1;
while (n>=t) t *= 10;
t /=10;
while (t>0) {
d = n/t;
n = n%t;
t /= 10;
if (turn) newnum = 10*newnum + d;
turn = (turn + 1) % 2;
}
return newnum;
}
int main () {
printf ("%d", gate(14362));
return 0;
}
The value printed by the given C program is _______ . (Answer in integer)
Correct answer: 46
Solution
Key idea: the function processes digits from the most significant to the least significant and appends every second digit to newnum, starting with the second digit from the left.
Initial setup: n = 14362, newnum = 0, turn = 0. The highest power of 10 t is set to 10000.
Iteration 1 (t = 10000): digit d = 14362 / 10000 = 1. Remaining n becomes 14362 % 10000 = 4362. turn = 0 so this digit is not appended. newnum = 0. turn becomes 1.
Iteration 2 (t = 1000): digit d = 4362 / 1000 = 4. Remaining n becomes 4362 % 1000 = 362. turn = 1 so append this digit: newnum = 0*10 + 4 = 4. turn becomes 0.
Iteration 3 (t = 100): digit d = 362 / 100 = 3. Remaining n becomes 362 % 100 = 62. turn = 0 so do not append. newnum stays 4. turn becomes 1.
Iteration 4 (t = 10): digit d = 62 / 10 = 6. Remaining n becomes 62 % 10 = 2. turn = 1 so append this digit: newnum = 4*10 + 6 = 46. turn becomes 0.
Iteration 5 (t = 1): digit d = 2 / 1 = 2. Remaining n becomes 0. turn = 0 so do not append. Final newnum remains 46.
Answer: 46
A video solution is available for this question — log in and enroll to watch it.
- Q67.GATE 2025
The maximum value of 𝑥 such that the edge between the nodes B and C is included in every minimum spanning tree of the given graph is _________ . (answer in integer)

Correct answer: 5
Solution
Answer: 5
Reasoning:
Key fact: An edge appears in every minimum spanning tree if there exists a cut separating its endpoints for which that edge is the unique minimum-weight edge crossing the cut.
Consider cuts that separate node B and node C. Evaluate each cut and the crossing edge weights:
Cut with set {B}: crossing edges are AB = 7, BD = 3, and BC = x. For BC to be the unique minimum here requires x < 3, so x ≤ 2 (integer).
Cut with set {B, D}: crossing edges are AB = 7, AD = 6, DC = 8, and BC = x. For BC to be the unique minimum here requires x < 6, so x ≤ 5 (integer).
Cuts {B, A} and {B, A, D} have AC = 1 crossing, so BC cannot be the unique minimum for those cuts unless x < 1, which is not relevant for maximizing x.
Because we only need one cut where BC is the unique minimum, the best (largest) integer upper bound comes from the cut {B, D}, giving x ≤ 5.
Therefore, the maximum integer value of x that guarantees the edge between B and C is included in every minimum spanning tree is 5.
A video solution is available for this question — log in and enroll to watch it.
- Q68.GATE 2025
In a double hashing scheme,
\(ℎ_1 (𝑘) = 𝑘 \ mod \ 11\)and\(ℎ_2 (𝑘) = 1 + (𝑘 \ mod \ 7)\)are the auxiliary hash functions. The size\(m\)of the hash table is 11. The hash function for the\(i\)-th probe in the open address table is\([ℎ_1 (𝑘) + 𝑖 \ ℎ_2(𝑘)] \ mod \ 𝑚\). The following keys are inserted in the given order: 63, 50, 25, 79, 67, 24.The slot at which key 24 gets stored is ___________. (Answer in integer)
Correct answer: 10
Solution
Insert the keys in the given order and compute h1 and h2 for each to find the probe sequence.
Key 63: h1 = 63 mod 11 = 8; h2 = 1 + (63 mod 7) = 1. Probe i=0 -> slot (8 + 0*1) mod 11 = 8. Place 63 at slot 8.
Key 50: h1 = 50 mod 11 = 6; h2 = 1 + (50 mod 7) = 2. Probe i=0 -> slot 6. Place 50 at slot 6.
Key 25: h1 = 25 mod 11 = 3; h2 = 1 + (25 mod 7) = 5. Probe i=0 -> slot 3. Place 25 at slot 3.
Key 79: h1 = 79 mod 11 = 2; h2 = 1 + (79 mod 7) = 3. Probe i=0 -> slot 2. Place 79 at slot 2.
Key 67: h1 = 67 mod 11 = 1; h2 = 1 + (67 mod 7) = 5. Probe i=0 -> slot 1. Place 67 at slot 1.
Key 24: h1 = 24 mod 11 = 2; h2 = 1 + (24 mod 7) = 4.
Probe i=0 -> slot (2 + 0*4) mod 11 = 2 (occupied by 79).
Probe i=1 -> slot (2 + 1*4) mod 11 = 6 (occupied by 50).
Probe i=2 -> slot (2 + 2*4) mod 11 = (2 + 8) mod 11 = 10 (free). Place 24 at slot 10.
Final answer: 10 (slot 10)
A video solution is available for this question — log in and enroll to watch it.
- Q69.GATE 2025
Despite his initial hesitation, Rehman’s _________ to contribute to the success of the project never wavered.
Select the most appropriate option to complete the above sentence.
- A.
ambivalence
- B.
satisfaction
- C.
resolve
- D.
revolve
Correct answer: C
Solution
Correct answer: resolve
Explanation: Resolve means firm determination. The sentence expresses that although Rehman hesitated at first, his determination to contribute remained steady. "Resolve to contribute" is a natural collocation and accurately conveys this meaning.
ambivalence: Means mixed or conflicting feelings. Using it here would imply persistent indecision, which does not match the intended contrast and is less natural grammatically (we usually say "ambivalence about contributing").
satisfaction: Means contentment or pleasure; it does not express persistence or determination and does not fit the sentence meaning or common phrasing.
resolve: Correct choice. It clearly denotes steady determination and fits the structure "his resolve to [do something] never wavered."
revolve: A verb meaning to move in a circle or to center on something; it is irrelevant to the intended meaning and ungrammatical in this context.
Tip: Look for a word that expresses steady determination and fits the collocation "to contribute." That will help you choose the most appropriate option.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q70.GATE 2025
Bird : Nest :: Bee : _______
Select the correct option to complete the analogy.
- A.
Kennel
- B.
Hammock
- C.
Hive
- D.
Lair
Correct answer: C
Solution
Correct answer: Hive
Explanation: The analogy pairs an animal with its typical home. A bird lives in a nest; similarly, a bee lives in a hive.
Identify the relationship: "bird : nest" shows an animal matched to its home.
Apply the same relationship to bee: the typical home for bees is a hive.
Eliminate other choices: a kennel is for dogs, a hammock is a human bed, and a lair is a den for predators—none are bee homes.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q71.GATE 2025
If
\(P{e^x} = Qe^{-x} \)for all real values of 𝑥, which one of the following statements is true?- A.
\(𝑃 = 𝑄 = 0\) - B.
\(𝑃 = 𝑄 = 1\) - C.
\(𝑃 = 1; 𝑄 = −1\) - D.
\(\frac{P}{Q} = 0 \)
Correct answer: A
Solution
Reasoning: Multiply both sides of the given equation by e^x.
This gives P e^{2x} = Q for all real x.
If P ≠ 0 then e^{2x} would equal the constant Q/P for all x, but e^{2x} varies with x. This is impossible, so P must be 0.
With P = 0 the original equation becomes 0 = Q e^{-x} for all x, which forces Q = 0.
Conclusion: The only pair (P, Q) that satisfies the equation for every real x is P = Q = 0.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q72.GATE 2025
The paper as shown in the figure is folded to make a cube where each square corresponds to a particular face of the cube. Which one of the following options correctly represents the cube?
Note: The figures shown are representative.

Solution
Answer: The cube that shows the hollow triangle on the front, the filled circle on the top, and the filled small triangle on the right matches the net.
Key steps to see why:
Identify the centre square of the net as the front face; it contains the hollow triangle.
The square directly above the centre becomes the top face when folded; that square contains the filled circle, so the top of the cube must show the filled circle.
The square directly to the right of the centre becomes the right face; it contains the filled small triangle, so the right face must show that filled small triangle.
The square below the centre becomes the bottom face and carries the hollow circle; this mark will not be visible from the front view but must be in that position.
Compare candidate cubes by checking these relative positions (front, top, right, bottom). The correct cube is the one that places the hollow triangle on the front, the filled circle on the top, and the filled small triangle on the right.
A video solution is available for this question — log in and enroll to watch it.
- Q73.GATE 2025
Let 𝑝1 and 𝑝2 denote two arbitrary prime numbers. Which one of the following statements is correct for all values of 𝑝1 and 𝑝2?
- A.
𝑝1 + 𝑝2 is not a prime number.
- B.
𝑝1𝑝2 is not a prime number.
- C.
𝑝1 + 𝑝2 + 1 is a prime number.
- D.
𝑝1𝑝2 + 1 is a prime number.
Correct answer: B
Solution
Answer: The product of the two primes is not a prime number.
Reason: If p1 and p2 are prime numbers (both at least 2), then p1·p2 has divisors p1 and p2 and is greater than 1, so p1·p2 is composite and therefore not prime.
Counterexamples showing the other statements fail in general:
The claim that the sum of the primes is not prime is false: for example 2 + 3 = 5, which is prime.
The claim that the sum of the primes plus one is always prime is false: for example 2 + 3 + 1 = 6, which is not prime.
The claim that the product of the primes plus one is always prime is false: for example 3·5 + 1 = 16, which is not prime (though sometimes p1·p2 + 1 can be prime, e.g. 2·3 + 1 = 7).
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q74.GATE 2025
Based only on the conversation below, identify the logically correct inference:
“Even if I had known that you were in the hospital, I would not have gone there to see you”, Ramya told Josephine.
- A.
Ramya knew that Josephine was in the hospital.
- B.
Ramya did not know that Josephine was in the hospital.
- C.
Ramya and Josephine were once close friends; but now, they are not.
- D.
Josephine was in the hospital due to an injury to her leg.
Correct answer: B
Solution
Correct inference: Ramya did not know that Josephine was in the hospital.
Why: The sentence uses a counterfactual/hypothetical construction ("Even if I had known..."). Using this form typically indicates that the speaker did not, in fact, have that knowledge; they are describing what would have happened under a hypothetical condition.
What else can be inferred: The speaker also expresses that she would not have visited even if she had known, so the statement conveys both lack of knowledge and the speaker's stance that she would not have gone to visit.
Why the other interpretations fail: There is no information about their past or present friendship, and there is no information about the cause of hospitalisation. Those claims introduce facts not present in the sentence.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q75.GATE 2025
If IMAGE and FIELD are coded as FHBNJ and EMFJG respectively then, which one among the given options is the most appropriate code for BEACH ?
- A.
CEADP
- B.
IDBFC
- C.
JGIBC
- D.
IBCEC
Correct answer: B
Solution
Rule: Reverse the word, then replace each letter with the next letter in the alphabet (Z -> A).
Apply the rule to BEACH:
Step 1: Reverse BEACH -> H C A E B
Step 2: Shift each letter forward by one: H -> I, C -> D, A -> B, E -> F, B -> C
Result: IDBFC
Check with the given examples to verify the rule:
IMAGE -> reverse to E G A M I -> shift each forward -> F H B N J (matches the given encoding)
FIELD -> reverse to D L E I F -> shift each forward -> E M F J G (matches the given encoding)
Conclusion: Applying the rule to BEACH produces IDBFC, so the correct coded form is IDBFC. The originally indicated answer CEADP is not consistent with this rule.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q76.GATE 2025
Which one of the following options is correct for the given data in the table?
\(\begin{array}{|c|c|c|c|c|} \hline \text{Iteration (i)} & \text{0} & \text{1} & \text{2} & \text{3} \\ \hline \text{Input (I)} & \text{20} & \text{-4} & \text{10} & \text{15} \\ \hline \text{Output (X)} & \text{20} & \text{16} & \text{26} & \text{41} \\ \hline \text{Output (Y)} & \text{20} & \text{-80} & \text{-800} & \text{-12000} \\ \hline \end{array}\)- A.
\(𝑋(𝑖) = 𝑋(𝑖 − 1) + 𝐼(𝑖); 𝑌(𝑖) = 𝑌(𝑖 − 1)𝐼(𝑖); 𝑖 > 0\) - B.
\(𝑋(𝑖) = 𝑋(𝑖 − 1)𝐼(𝑖); 𝑌(𝑖) = 𝑌(𝑖 − 1) + 𝐼(𝑖); 𝑖 > 0\) - C.
\(𝑋(𝑖) = 𝑋(𝑖 − 1)𝐼(𝑖); 𝑌(𝑖) = 𝑌(𝑖 − 1)𝐼(𝑖); 𝑖 > 0\) - D.
\(𝑋(𝑖) = 𝑋(𝑖 − 1) + 𝐼(𝑖); 𝑌(𝑖) = 𝑌(𝑖 − 1)𝐼(𝑖 − 1); 𝑖 > 0\)
Correct answer: A
Solution
Solution overview: find the recurrences that reproduce the table of values.
Determine how each output changes from one iteration to the next:
X recurrence: X(i) = X(i-1) + I(i)
i = 1: X1 = 20 + (-4) = 16
i = 2: X2 = 16 + 10 = 26
i = 3: X3 = 26 + 15 = 41
Y recurrence: Y(i) = Y(i-1) × I(i)
i = 1: Y1 = 20 × (-4) = -80
i = 2: Y2 = -80 × 10 = -800
i = 3: Y3 = -800 × 15 = -12000
Conclusion: The recurrences that match every row of the table are X(i) = X(i-1) + I(i) and Y(i) = Y(i-1) × I(i) for i > 0.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q77.GATE 2025
In the given figure, PQRS is a square of side 2 cm and PLMN is a rectangle. The corner L of the rectangle is on the side QR. Side MN of the rectangle passes through the corner S of the square.
What is the area (in
\(cm^2\)) of the rectangle PLMN?Note: The figure shown is representative.

- A.
\(2\sqrt{2}\) - B.
\(2\) - C.
\(8\) - D.
\(4\)
Correct answer: D
Solution
Let the square have coordinates P = (0, 2), Q = (0, 0), R = (2, 0), and S = (2, 2). Since L lies on QR, write L = (x, 0), where 0 <= x <= 2.
One side of rectangle PLMN is vector PL = (x, -2). The adjacent side PN must be perpendicular to PL, so take PN = k(2, x) for some scale factor k.
The side MN is parallel to PL and passes through S. Hence S can be written as P + PN + t PL for some t between 0 and 1.
Using coordinates:
(0, 2) + k(2, x) + t(x, -2) = (2, 2).So,
2k + tx = 2,
xk - 2t = 0.From xk - 2t = 0, t = xk/2. Substituting in 2k + tx = 2 gives
k(2 + x^2/2) = 2,
so k = 4/(x^2 + 4).Area of rectangle PLMN = |PL| × |PN|
= sqrt(x^2 + 4) × k sqrt(x^2 + 4)
= k(x^2 + 4)
= 4.Therefore, the area of rectangle PLMN is 4 cm^2.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q78.GATE 2025
The diagram below shows a river system consisting of 7 segments, marked P, Q, R, S, T, U, and V. It splits the land into 5 zones, marked Z1, Z2, Z3, Z4, and Z5. We need to connect these zones using the least number of bridges. Out of the following options, which one is correct?
Note: The figure shown is representative.

- A.
Bridges on P, Q, and T
- B.
Bridges on P, Q, S, and T
- C.
Bridges on Q, R, T, and V
- D.
Bridges on P, Q, S, U, and V
Correct answer: C
Solution
Treat each land zone as a vertex of a graph and each river segment as a possible edge/bridge between the two zones separated by that segment. To connect 5 zones with the least number of bridges, we need a spanning tree, which has exactly 5 - 1 = 4 bridges.
From the diagram, bridges on Q, R, T and V connect the zones in a chain/tree:
Z1 --Q-- Z2 --R-- Z3 --T-- Z5, and Z3 --V-- Z4.Thus all five zones are connected using exactly 4 bridges, which is the minimum possible. Hence the correct option is: bridges on Q, R, T and V.
- A.
- Q79.GATE 2025
If
\(A = \begin{pmatrix} 1 & 2 \\ 2 & -1 \end{pmatrix} \),then which ONE of the following is\(A^8\)?- A.
\(\begin{pmatrix} 25 & 0 \\ 0 & 25 \end{pmatrix} \) - B.
\(\begin{pmatrix} 125 & 0 \\ 0 & 125 \end{pmatrix} \) - C.
\(\begin{pmatrix} 625 & 0 \\ 0 & 625 \end{pmatrix} \) - D.
\(\begin{pmatrix} 3125 & 0 \\ 0 & 3125 \end{pmatrix} \)
Correct answer: C
Solution
Key step: compute A^2 and use powers of that result.
Start with the matrix A = [[1, 2], [2, -1]].
Compute A^2 by multiplying A with itself:
A^2 = [[1*1 + 2*2, 1*2 + 2*(-1)], [2*1 + (-1)*2, 2*2 + (-1)*(-1)]] = [[5, 0], [0, 5]] = 5 I.
Therefore A^8 = (A^2)^4 = (5 I)^4 = 5^4 I = 625 I.
Final answer: A^8 = [[625, 0], [0, 625]].
Common mistakes:
[[25, 0], [0, 25]] equals A^4 because it is (A^2)^2 = 5^2 I.
[[125, 0], [0, 125]] equals A^6 because it is (A^2)^3 = 5^3 I.
[[3125, 0], [0, 3125]] equals A^10 because it is (A^2)^5 = 5^5 I.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q80.GATE 2025
The value of
\(x\)such that\(𝑥 > 1\), satisfying the equation\(\int_1^x t \ln t \, dt = \frac 1 4\)is- A.
\(\sqrt{e}\) - B.
\(e\) - C.
\(e^2\) - D.
\(𝑒 − 1\)
Correct answer: A
Solution
Solution:
Compute the integral by parts.
Let u = ln t and dv = t dt. Then du = dt/t and v = t^2/2.
An antiderivative is (t^2/2) ln t - t^2/4. Evaluating from 1 to x gives (x^2/2) ln x - x^2/4 + 1/4.
Set this equal to 1/4 and simplify: (x^2/2) ln x - x^2/4 = 0, which is (x^2/4)(2 ln x - 1) = 0.
For x > 1 we have x^2/4 ≠ 0, so 2 ln x - 1 = 0. Thus ln x = 1/2 and x = e^{1/2} = sqrt(e).
Therefore the required value of x (with x > 1) is sqrt(e).
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q81.GATE 2025
Consider a binary tree 𝑇 in which every node has either zero or two children. Let 𝑛 > 0 be the number of nodes in 𝑇.
Which ONE of the following is the number of nodes in 𝑇 that have exactly two children?
- A.
\(\frac{n - 2}{2}\) - B.
\(\frac{n - 1}{2}\) - C.
\(\frac{n }{2}\) - D.
\(\frac{n + 1}{2}\)
Correct answer: B
Solution
Answer: the number of nodes with exactly two children is (n - 1)/2.
Derivation:
Let I be the number of nodes that have exactly two children (internal nodes).
Let L be the number of leaves (nodes with zero children).
Total nodes n = I + L.
Each internal node has two children, so the total number of child links is 2I. Those child links account for every node except the root, so 2I = n - 1.
Solve 2I = n - 1 to get I = (n - 1)/2.
Remark: this also implies n = 2I + 1, so n is always odd for such trees.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q82.GATE 2025
Let L, M, and N be non-singular 3×3 matrices such that:
L^2=L^−1,M=L^8,N=L^2
You have to find the value of the determinant of the matrix (M−N) and select the correct option from the given choices.
- A.
0
- B.
1
- C.
2
- D.
3
Correct answer: A
Solution
Key insight: use the relation L^2 = L^{-1} to reduce powers of L.
Step 1: From L^2 = L^{-1}, multiply both sides on the right by L to get L^3 = I.
Step 2: Reduce powers of L modulo 3. Since 8 ≡ 2 (mod 3), M = L^8 = L^2.
Step 3: Given N = L^2, we have M = L^2 and N = L^2, so M − N is the zero matrix.
Conclusion: The determinant of the zero 3×3 matrix is 0, so det(M − N) = 0.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q83.GATE 2025
Consider the following statements:
(i) Address Resolution Protocol (ARP) provides a mapping from an IP address to the corresponding hardware (link-layer) address.
(ii) A single TCP segment from a sender S to a receiver R cannot carry both data from S to R and acknowledgement for a segment from R to S.
Which ONE of the following is CORRECT?
- A.
Both (i) and (ii) are TRUE
- B.
(i) is TRUE and (ii) is FALSE
- C.
(i) is FALSE and (ii) is TRUE
- D.
Both (i) and (ii) are FALSE
Correct answer: B
Solution
Answer: (i) is TRUE and (ii) is FALSE.
Explanation for (i): ARP provides a mapping from an IP address to the corresponding hardware (link-layer) address (for example, an IPv4 address to a MAC address) on a local network.
Explanation for (ii): This statement is false. TCP acknowledgements are part of the TCP header and can be piggybacked on segments that also carry data. If a host has received data from its peer, it can send a segment containing its own data and include the ACK number acknowledging the peer's data in the same segment.
Therefore, the correct choice is the option stating that the first statement is true and the second statement is false.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q84.GATE 2025
Consider the routing protocols given in List I and the names given in List II:
\(\begin{array}{|ll|ll|}\hline & \textbf{List I} & & \textbf{List II} \\\hline \text{(i)} & \text{Distance Vector routing} & \text{(a)}& \text{Bellman-Ford} \\\hline \text{(ii)}& \text{Link state routing} & \text{(b)} & \text{Dijkstra} \\\hline \end{array}\)For matching of items in List I with those in List II, which ONE of the following options is CORRECT?
- A.
(i) – (a) and (ii) – (b)
- B.
(i) – (a) and (ii) – (a)
- C.
(i) – (b) and (ii) – (a)
- D.
(i) – (b) and (ii) – (b)
Correct answer: A
Solution
Correct matching: Distance Vector routing → Bellman-Ford; Link State routing → Dijkstra.
Why:
Distance Vector routing: Each router maintains and periodically exchanges a vector of distances to destinations with its neighbors and updates distances by iterative relaxation. This behavior corresponds to the Bellman-Ford algorithm.
Link State routing: Each router floods link-state information so every router can build the complete network graph, then computes shortest paths from itself using Dijkstra's algorithm.
Conclusion: Distance Vector pairs with Bellman-Ford and Link State pairs with Dijkstra, so the matching given by Distance Vector → Bellman-Ford and Link State → Dijkstra is correct.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q85.GATE 2025
A machine receives an IPv4 datagram. The protocol field of the IPv4 header has the protocol number of a protocol X. Which ONE of the following is NOT a possible candidate for X?
- A.
Internet Control Message Protocol (ICMP)
- B.
Internet Group Management Protocol (IGMP)
- C.
Open Shortest Path First (OSPF)
- D.
Routing Information Protocol (RIP)
Correct answer: D
Solution
Answer: Routing Information Protocol (RIP) is NOT a possible candidate for the IPv4 protocol field.
Key idea: the IPv4 protocol field identifies the next-level protocol by an assigned protocol number. Some protocols are carried directly over IP and therefore have their own protocol numbers; other protocols are carried inside transport protocols such as UDP or TCP.
Internet Control Message Protocol (ICMP) is carried directly over IP and uses IPv4 protocol number 1, so it can appear in the protocol field.
Internet Group Management Protocol (IGMP) is carried directly over IP and uses IPv4 protocol number 2, so it can appear in the protocol field.
Open Shortest Path First (OSPF) is carried directly over IP and uses IPv4 protocol number 89, so it can appear in the protocol field.
Routing Information Protocol (RIP) is transported inside UDP (uses UDP port 520). The IPv4 protocol field would therefore indicate UDP (protocol number 17), not RIP itself, so RIP cannot be the protocol number in the IPv4 header.
Therefore, the correct answer is Routing Information Protocol (RIP).
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q86.GATE 2025
Consider the following C program:
#include <stdio.h>
void stringcopy(char *, char *);
int main() {
char a[30] = "@#Hello World!";
stringcopy(a, a + 2); // Copy from a+2 to a
printf("%s\n", a);
return 0;
}void stringcopy(char *s, char *t) {
while (*t)
*s++ = *t++;
}Which ONE of the following will be the output of the program?
- A.
@#Hello World!
- B.
Hello World!
- C.
ello World!
- D.
Hello World!d!
Correct answer: D
Solution
Answer: Hello World!d!
Key insight: The function copies characters from a+2 into a but does not copy the terminating null byte, so leftover characters after the copied region remain in the array and become part of the printed string.
Start: the array a initially contains: index 0='@', 1='#', 2='H', 3='e', 4='l', 5='l', 6='o', 7=' ', 8='W', 9='o', 10='r', 11='l', 12='d', 13='!', 14='\0'.
stringcopy(a, a+2) sets s = a (index 0) and t = a+2 (index 2). Each loop iteration copies *t to *s and increments both pointers, so characters at indices 2..13 are copied into positions 0..11.
After copying, a[0..11] contain 'H','e','l','l','o',' ','W','o','r','l','d','!'. The loop then stops when *t is the original terminating '\0' at index 14, but that '\0' is not written into the destination because the code stops before copying it.
Indices 12 and 13 remain their original characters 'd' and '!', so the characters from index 0 up to the original null produce the string "Hello World!d!".
Therefore the program prints: Hello World!d!
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q87.GATE 2025
Consider an unordered list of 𝑁 distinct integers.
What is the minimum number of element comparisons required to find an integer in the list that is NOT the largest in the list?
- A.
1
- B.
𝑁 − 1
- C.
𝑁
- D.
2𝑁 − 1
Correct answer: A
Solution
Answer: 1 — one comparison is sufficient to find an element that is not the largest (for N ≥ 2).
Why one comparison is sufficient:
Pick any two elements and compare them. The smaller of the two cannot be the largest in the whole list, so it is a valid non-largest element.
Why zero comparisons are not sufficient:
With no comparisons you must choose an element without information. That chosen element might be the largest, so you cannot guarantee correctness in the worst case. Therefore at least one comparison is necessary.
Edge case: If N = 1 there is no element that is not the largest; the statement assumes N ≥ 2.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q88.GATE 2025
Consider the following statements about the use of backpatching in a compiler for intermediate code generation:
(I) Backpatching can be used to generate code for Boolean expressions in one pass.
(II) Backpatching can be used to generate code for flow-of-control statements in one pass.
Which ONE of the following options is CORRECT?
- A.
Only (I) is correct.
- B.
Only (II) is correct.
- C.
Both (I) and (II) are correct.
- D.
Neither (I) nor (II) is correct.
Correct answer: C
Solution
Answer: Both (I) and (II) are correct.
Backpatching postpones filling in jump targets until the target instruction address becomes known. During code generation, the compiler emits jump instructions with blank targets and maintains lists of those incomplete jumps.
For Boolean expressions, backpatching uses lists such as truelist and falselist. These lists allow the compiler to emit conditional jumps in one pass and patch their target addresses later.
For flow-of-control statements, backpatching is also used in one-pass intermediate-code generation. Constructs such as if-then, if-then-else, and while statements use lists such as nextlist, truelist, and falselist so that forward jumps can be patched when their targets are known.
Therefore, statement (I) is true and statement (II) is also true.
Correct Answer: Option C.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q89.GATE 2025
Given the following syntax directed translation rules:
Rule 1: 𝑅 → 𝐴𝐵 {𝐵. 𝑖 = 𝑅. 𝑖 − 1; 𝐴. 𝑖 = 𝐵. 𝑖; 𝑅. 𝑖 = 𝐴. 𝑖 + 1;}
Rule 2: 𝑃 → 𝐶𝐷 {𝑃. 𝑖 = 𝐶. 𝑖 + 𝐷. 𝑖;𝐷. 𝑖 = 𝐶. 𝑖 + 2;}
Rule 3: 𝑄 → 𝐸𝐹 {𝑄. 𝑖 = 𝐸. 𝑖 + 𝐹. 𝑖;}
Which ONE is the CORRECT option among the following?
- A.
Rule 1 is S-attributed and L-attributed; Rule 2 is S-attributed and not L-attributed; Rule 3 is neither S-attributed nor L-attributed
- B.
Rule 1 is neither S-attributed nor L-attributed; Rule 2 is S-attributed and Lattributed; Rule 3 is S-attributed and L-attributed
- C.
Rule 1 is neither S-attributed nor L-attributed; Rule 2 is not S-attributed and is L-attributed; Rule 3 is S-attributed and L-attributed
- D.
Rule 1 is S-attributed and not L-attributed; Rule 2 is not S-attributed and is L-attributed; Rule 3 is S-attributed and L-attributed
Correct answer: C
Solution
Final classification (correct answer): Rule 1 is neither S-attributed nor L-attributed; Rule 2 is not S-attributed and is L-attributed; Rule 3 is S-attributed and L-attributed.
Key reasons:
Rule 1: This rule is neither S-attributed nor L-attributed. It is not S-attributed because the semantic action uses R.i to set B.i before R.i itself is computed for the left-hand side, so the production requires an inherited value for R.i (S-attributed grammars allow only synthesized attributes). It is not L-attributed because A.i is assigned from B.i (a right sibling). L-attributed inherited attributes of a symbol may depend only on the parent and on attributes of symbols to its left, so depending on a right sibling violates the L-attributed restriction.
Rule 2: This rule is L-attributed but not S-attributed. The attribute D.i for the right child is assigned from C.i (the left sibling), so D.i is an inherited attribute that depends only on a left sibling, which fits the L-attributed form. Because an inherited attribute is present (D.i), the production is not S-attributed (S-attributed grammars permit only synthesized attributes).
Rule 3: This rule is S-attributed because the parent attribute Q.i is computed solely from the synthesized attributes E.i and F.i of its children. Since it is S-attributed (only synthesized attributes used), it also satisfies the requirements for being L-attributed.
Therefore, the option that states: "Rule 1 is neither S-attributed nor L-attributed; Rule 2 is not S-attributed and is L-attributed; Rule 3 is S-attributed and L-attributed" is the correct choice.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q90.GATE 2025
Consider a network that uses Ethernet and IPv4. Assume that IPv4 headers do not use any options field. Each Ethernet frame can carry a maximum of 1500 bytes in its data field. A UDP segment is transmitted. The payload (data) in the UDP segment is 7488 bytes.
Which ONE of the following choices has the CORRECT total number of fragments transmitted and the size of the last fragment including IPv4 header?
- A.
5 fragments, 1488 bytes
- B.
6 fragments, 88 bytes
- C.
6 fragments, 108 bytes
- D.
6 fragments, 116 bytes
Correct answer: D
Solution
Correct answer: 6 fragments, last fragment size 116 bytes (including the 20-byte IPv4 header).
Step-by-step calculation:
Total UDP segment size (IP payload) = UDP header (8 bytes) + UDP data (7488 bytes) = 7496 bytes.
Maximum IP payload per fragment = Ethernet data field max (1500 bytes) - IPv4 header (20 bytes) = 1480 bytes.
Number of full-size fragments = floor(7496 / 1480) = 5, which carry 5 × 1480 = 7400 bytes.
Remainder for the last fragment = 7496 - 7400 = 96 bytes of IP payload.
Total number of fragments = 5 full fragments + 1 last fragment = 6 fragments.
Size of the last fragment including the IPv4 header = IPv4 header (20 bytes) + last fragment IP payload (96 bytes) = 116 bytes.
Common mistakes to avoid:
Forgetting to add the 8-byte UDP header to the UDP payload when computing the total IP payload to fragment.
Using the Ethernet MTU (1500) directly without subtracting the IPv4 header to find the usable IP payload per fragment.
Ignoring that fragment payload sizes (except possibly the last) must align with the 8-byte fragmentation unit; here 1480 is divisible by 8, so it is valid.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q91.GATE 2025
Which ONE of the following languages is accepted by a deterministic pushdown automaton?
- A.
Any regular language.
- B.
Any context-free language.
- C.
Any language accepted by a non-deterministic pushdown automaton.
- D.
Any decidable language.
Correct answer: A
Solution
Answer: Any regular language.
Reasoning:
Deterministic pushdown automata (DPDA) recognize deterministic context-free languages (DCFLs).
Every regular language is deterministic context-free because a DPDA can simulate a deterministic finite automaton by not using the stack (or using it in a trivial deterministic way). Thus every regular language is accepted by some DPDA.
Not all context-free languages are deterministic context-free. For example, the language of palindromes over {a,b} is context-free but cannot be recognized by any DPDA, so the statement that every context-free language is accepted by a DPDA is false.
Languages accepted by nondeterministic pushdown automata are exactly the context-free languages; since some of these are not deterministic, not every language an NPDA accepts can be accepted by a DPDA.
Decidable languages form a much larger class that includes languages which are not context-free (for example, {a^n b^n c^n | n ≥ 0} is decidable but not context-free), so they are not all accepted by DPDAs.
Therefore, among the given choices, the only class guaranteed to be accepted by a deterministic pushdown automaton is the class of regular languages.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q92.GATE 2025
Let
\(𝐺_1, 𝐺_2 \)be Context Free Grammars (CFGs) and\(𝑅\)be a regular expression. For a grammar\(G\), let\(𝐿(𝐺)\)denote the language generated by\(G\).Which ONE among the following questions is decidable?
- A.
\(Is 𝐿(𝐺_1) = 𝐿(𝐺_2)?\) - B.
\(Is 𝐿(𝐺_1) ∩ 𝐿(𝐺_2) = ∅?\) - C.
\(Is 𝐿(𝐺_1) = 𝐿(𝑅)?\) - D.
\(Is 𝐿(𝐺_1) = ∅?\)
Correct answer: D
Solution
Answer: The only decidable question among the list is "Is L(G1) = ∅?"
Why this is decidable:
There is a standard algorithm to decide emptiness of a context-free grammar.
Algorithm (marking/generating-variable method):
Initialize a set M of nonterminals that have a production whose right-hand side is composed entirely of terminals.
Repeat: add any nonterminal A to M if there is a production A → α where every symbol of α is either a terminal or already in M.
When no new nonterminals can be added, check whether the start symbol is in M. If it is, the grammar generates at least one string (so L(G) ≠ ∅); otherwise L(G) = ∅.
Why the other questions are not decidable (sketches):
Equivalence of two arbitrary context-free grammars is undecidable. There is no algorithm that decides for every pair of CFGs whether they generate the same language.
Emptiness of the intersection of two context-free languages is undecidable. Deciding whether L(G1) ∩ L(G2) is empty is known to be an undecidable problem.
Equality between an arbitrary context-free language and a given regular language is not generally decidable; there is no uniform algorithm that solves this equality test in all cases.
Therefore the decidable question among the provided choices is the emptiness test for a single CFG.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q93.GATE 2025
An audit of a banking transactions system has found that on an earlier occasion, two joint holders of account 𝐴 attempted simultaneous transfers of Rs. 10000 each from account 𝐴 to account 𝐵. Both transactions read the same value, Rs. 11000, as the initial balance in 𝐴 and were allowed to go through. 𝐵 was credited Rs. 10000 twice. 𝐴 was debited only once and ended up with a balance of Rs. 1000.
Which of the following properties is/are certain to have been violated by the system?
- A.
Atomicity
- B.
Consistency
- C.
Isolation
- D.
Durability
Correct answer: B, C
Solution
The system has certainly violated Isolation and Consistency.
Isolation: Both transactions read the same initial balance (₹11000) and executed concurrently, causing a lost update.
Consistency: The account invariant was violated (₹20000 credited to B, but A debited only once).
Durability is not involved here.
Atomicity is not certain to be violated because each transaction may still have completed fully on its own.A video solution is available for this question — log in and enroll to watch it.
- A.
- Q94.GATE 2025
Which of the following is/are part of an Instruction Set Architecture of a processor?
- A.
The size of the cache memory
- B.
The clock frequency of the processor
- C.
The number of cache memory levels
- D.
The total number of registers
Correct answer: D
Solution
Answer: The total number of registers is part of the Instruction Set Architecture (ISA).
Why:
The ISA defines programmer-visible state and behavior, including the instruction set, data types and sizes, addressing modes, instruction formats/encodings, and the architected register set (how many registers and their roles).
Contrast with microarchitectural features:
Cache size and the number of cache levels are implementation choices that affect performance but do not change the ISA.
Clock frequency and pipeline depth are hardware-performance parameters, also outside the ISA.
Summary:
Included in ISA: the total number of registers (architected register set) and other programmer-visible details.
Not part of ISA: cache size, number of cache levels, and clock frequency (these are microarchitectural).
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q95.GATE 2025
Which of the following statements regarding Breadth First Search (BFS) and Depth First Search (DFS) on an undirected simple graph G is/are TRUE?
- A.
A DFS tree of 𝐺 is a Shortest Path tree of 𝐺.
- B.
Every non-tree edge of G with respect to a DFS tree is a forward/back edge.
- C.
If (𝑢, 𝑣) is a non-tree edge of G with respect to a BFS tree, then the distances from the source vertex 𝑠 to 𝑢 and 𝑣 in the BFS tree are within ±1 of each other.
- D.
Both BFS and DFS can be used to find the connected components of G.
Correct answer: B, C, D
Solution
Final answer: The true statements are the following three statements (restated):
Every non-tree edge of G with respect to a DFS tree is a forward/back edge.
Reason: In an undirected graph, a non-tree edge encountered during DFS always connects a node to an ancestor in the DFS tree, so it is classified as a back edge (hence it fits the forward/back description). Forward and cross edges do not arise in undirected DFS.
If (u, v) is a non-tree edge of G with respect to a BFS tree, then the distances from the source vertex s to u and v in the BFS tree are within ±1 of each other.
Reason: BFS explores vertices in increasing distance from the source. The edge (u,v) gives an alternative path to v of length dist(s,u)+1 (and vice versa), so |dist(s,u) - dist(s,v)| ≤ 1.
Both BFS and DFS can be used to find the connected components of G.
Reason: Starting a BFS or DFS from any vertex visits its entire connected component. Repeating the search from any still-unvisited vertex enumerates all components.
Explanation for the incorrect statement (that a DFS tree is a shortest-path tree):
Counterexample: Take vertices s, v, w with edges (s,v), (v,w), and (s,w). A DFS starting at s that visits v first will then visit w via v, producing a tree path to w of length 2, even though the direct edge (s,w) gives distance 1. Thus a DFS tree need not be a shortest-path tree; BFS is the algorithm that produces shortest-path trees in unweighted graphs.
Conclusion: The correct statements are the three described above (every non-tree edge in DFS is a forward/back edge; BFS non-tree edges connect vertices whose distances differ by at most 1; and both searches can find connected components).
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q96.GATE 2025
Consider the two lists List I and List II given below:
\(\begin{array}{|l|l|}\hline \textbf{List I} & \textbf{List II} \\ \hline \text{Context-free languages} & \text{Closed under union} \\ \hline \text{Recursive languages} & \text{Not closed under complementation} \\ \hline \text{Regular languages} & \text{Closed under intersection} \\ \hline \end{array}\)For matching of items in List I with those in List II, which of the following option(s) is/are CORRECT?
- A.
(i) – (a), (ii) – (b), and (iii) – (c)
- B.
(i) – (b), (ii) – (a), and (iii) – (c)
- C.
(i) – (b), (ii) – (c), and (iii) – (a)
- D.
(i) – (a), (ii) – (c), and (iii) – (b)
Correct answer: B, C
Solution
Assessment of the matchings and final conclusion:
Context-free languages are not closed under complementation in general.
Recursive (decidable) languages are closed under union and also closed under intersection and complementation.
Regular languages are closed under union, intersection, and complementation.
Because more than one property from List II can correctly apply to a given class in List I, multiple matchings are possible. Two matchings from the provided options are fully true:
(i) → (b), (ii) → (a), (iii) → (c): Context-free languages not closed under complementation; recursive languages closed under union; regular languages closed under intersection.
(i) → (b), (ii) → (c), (iii) → (a): Context-free languages not closed under complementation; recursive languages closed under intersection; regular languages closed under union.
The mapping (i) → (a), (ii) → (b), (iii) → (c) is incorrect for the given wording because recursive languages are closed under complementation, so pairing recursive languages with “not closed under complementation” is false. Similarly, any mapping that pairs regular languages with “not closed under complementation” is false because regular languages are closed under complementation.
Final answer: The two provided matchings that are fully correct (given the listed properties) are the mappings stated above: (i) → (b), (ii) → (a), (iii) → (c) and (i) → (b), (ii) → (c), (iii) → (a). The originally marked mapping that pairs recursive languages with “not closed under complementation” is incorrect under the current wording.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q97.GATE 2025
Consider the following logic circuit diagram.

Which is/are the CORRECT option(s) for the output function 𝐹?
- A.
\(\overline{X Y}\) - B.
\(\overline{X}+\overline{Y}+X \overline{Y}\) - C.
\(\overline{XY}+\overline{X}+X \overline{Y}\) - D.
\(X+\overline{Y}\)
Correct answer: A, B, C
Solution
Key result: the output function F equals ¬(X·Y).
Step-by-step derivation:
Top gate: a NAND receiving X and Y, so its output is ¬(X·Y).
Middle inverter: inverts X, producing ¬X. This signal is one input to the final OR.
Bottom path: the inverter produces ¬X and the bottom AND receives X and ¬X, so that AND output is X·¬X = 0 (always false).
Final OR: combine the three inputs: ¬(X·Y) + ¬X + 0 = ¬(X·Y) + ¬X.
Use ¬(X·Y) = ¬X + ¬Y to see that ¬(X·Y) already includes ¬X, so the OR simplifies to ¬(X·Y).
Equivalence checks for the given algebraic expressions:
Expression ¬X + ¬Y + X·¬Y simplifies to ¬X + ¬Y (because ¬Y absorbs X·¬Y), which equals ¬(X·Y).
Expression ¬(X·Y) + ¬X + X·¬Y simplifies to ¬(X·Y) (because ¬(X·Y) = ¬X + ¬Y and that already covers the other terms).
Expression X + ¬Y is not equivalent; a counterexample is X=1, Y=1 where X+¬Y = 1 but ¬(X·Y) = 0.
Conclusion: the circuit implements F = ¬(X·Y). The two algebraic forms ¬X + ¬Y + X·¬Y and ¬(X·Y) + ¬X + X·¬Y are algebraically equivalent to ¬(X·Y), so they represent the same function; X + ¬Y does not.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q98.GATE 2025
The following two signed 2’s complement numbers (multiplicand M and multiplier Q) are being multiplied using Booth’s algorithm:
M: 1100 1101 1110 1101 and Q: 1010 0100 1010 1010
The total number of addition and subtraction operations to be performed is ___________. (Answer in integer)
Correct answer: 13
Solution
Final answer: 13 total operations (6 additions and 7 subtractions).
Reasoning:
Booth's algorithm examines pairs (q_i, q_{i-1}) for i = 0..15 after appending q_{-1} = 0. If the pair is 01, add the multiplicand; if 10, subtract the multiplicand; if 00 or 11, do nothing.
Write the multiplier bits from LSB to MSB and inspect each pair (q_i, q_{i-1}):
i=0: (0, 0) -> no operation
i=1: (1, 0) -> subtract
i=2: (0, 1) -> add
i=3: (1, 0) -> subtract
i=4: (0, 1) -> add
i=5: (1, 0) -> subtract
i=6: (0, 1) -> add
i=7: (1, 0) -> subtract
i=8: (0, 1) -> add
i=9: (0, 0) -> no operation
i=10: (1, 0) -> subtract
i=11: (0, 1) -> add
i=12: (0, 0) -> no operation
i=13: (1, 0) -> subtract
i=14: (0, 1) -> add
i=15: (1, 0) -> subtract
Count: additions = 6, subtractions = 7, total = 13.
A video solution is available for this question — log in and enroll to watch it.
- Q99.GATE 2025
int x = 126, y = 105;
do {
if (x > y) x = x - y;
else y = y - x;
} while (x != y);printf("%d", x);
The output of the given C code segment is ________. (Answer in integer)
Correct answer: 21
Solution
This code uses the subtraction form of the Euclidean algorithm to compute the greatest common divisor (GCD) of 126 and 105.
Initial values: x = 126, y = 105
Iteration 1: x > y, so x = x - y = 126 - 105 = 21. Now x = 21, y = 105.
Iteration 2: x < y, so y = y - x = 105 - 21 = 84. Now x = 21, y = 84.
Iteration 3: y = y - x = 84 - 21 = 63. Now x = 21, y = 63.
Iteration 4: y = y - x = 63 - 21 = 42. Now x = 21, y = 42.
Iteration 5: y = y - x = 42 - 21 = 21. Now x = 21, y = 21.
Loop ends because x == y.
Therefore the program prints 21. This is the GCD of 126 and 105.
A video solution is available for this question — log in and enroll to watch it.
- Q100.GATE 2025
In a 4-bit ripple counter, if the period of the waveform at the last flip-flop is 64 microseconds, then the frequency of the ripple counter in kHz is ________. (Answer in integer)
Correct answer: 250
Solution
Key idea: a 4-bit ripple counter divides the input clock frequency by 2^4 = 16, so the input frequency is 16 times the frequency at the last flip-flop.
Compute the frequency at the last flip-flop: f_last = 1 / T_last = 1 / 64 microseconds = 1 / 64e-6 s = 15,625 Hz.
Compute the input (counter) frequency: f_in = 16 × f_last = 16 × 15,625 Hz = 250,000 Hz = 250 kHz.
Answer: 250 kHz
A video solution is available for this question — log in and enroll to watch it.
- Q101.GATE 2025
Suppose the values 10, −4, 15, 30, 20, 5, 60, 19 are inserted in that order into an initially empty binary search tree. Let 𝑇 be the resulting binary search tree. The number of edges in the path from the node containing 19 to the root node of 𝑇 is ___________. (Answer in integer)
Correct answer: 4
Solution
Solution: Build the binary search tree by inserting the values in the given order and then find the path from the node containing 19 up to the root.
Insert 10: becomes the root.
Insert -4: goes to the left of 10.
Insert 15: goes to the right of 10.
Insert 30: compare with 10 (right), then with 15 (right), so it becomes the right child of 15.
Insert 20: go right from 10 to 15, right to 30, then 20 is less than 30, so it becomes the left child of 30.
Insert 5: go left from 10 to -4, then 5 is greater than -4, so it becomes the right child of -4.
Insert 60: go right from 10 to 15 to 30, then 60 is greater than 30, so it becomes the right child of 30.
Insert 19: go right from 10 to 15 to 30, then left to 20, and 19 is less than 20, so it becomes the left child of 20.
Therefore the path from the node containing 19 up to the root is:
19
20
30
15
10 (root)
Count the edges along this path: there are 5 nodes on the path, so the number of edges is 4.
Answer: 4
A video solution is available for this question — log in and enroll to watch it.
- Q102.GATE 2025
Suppose we are transmitting frames between two nodes using Stop-and-Wait protocol. The frame size is 3000 bits. The transmission rate of the channel is 2000 bps (bits/second) and the propagation delay between the two nodes is 100 milliseconds. Assume that the processing times at the source and destination are negligible. Also, assume that the size of the acknowledgement packet is negligible. Which ONE of the following most accurately gives the channel utilization for the above scenario in percentage?
- A.
88.23
- B.
93.75
- C.
85.44
- D.
66.67
Correct answer: A
Solution
Solution:
For Stop‑and‑Wait protocol, channel utilization U = (frame transmission time) / (frame transmission time + round‑trip propagation delay + any acknowledgement transmission time + processing times). Acknowledgement transmission time and processing times are given as negligible here, so:
Frame transmission time = frame size / transmission rate = 3000 bits / 2000 bps = 1.5 s.
Round‑trip propagation delay = 2 × 100 ms = 2 × 0.1 s = 0.2 s.
Total cycle time = 1.5 s + 0.2 s = 1.7 s.
Utilization = 1.5 / 1.7 ≈ 0.88235 = 88.235% ≈ 88.23%.
Therefore the most accurate channel utilization for the given scenario is 88.23%.
Common mistakes to avoid:
Using only one propagation delay instead of the round‑trip propagation (this overestimates utilization).
Forgetting to convert milliseconds to seconds when adding propagation delay.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q103.GATE 2025
Let 𝐺 be an edge-weighted undirected graph with positive edge weights. Suppose a positive constant 𝛼 is added to the weight of every edge.
Which ONE of the following statements is TRUE about the minimum spanning trees (MSTs) and shortest paths (SPs) in 𝐺 before and after the edge weight update?
- A.
Every MST remains an MST, and every SP remains an SP.
- B.
MSTs need not remain MSTs, and every SP remains an SP.
- C.
Every MST remains an MST, and SPs need not remain SPs.
- D.
MSTs need not remain MSTs, and SPs need not remain SPs.
Correct answer: C
Solution
Final statement: Every minimum spanning tree remains a minimum spanning tree, and shortest paths need not remain shortest paths.
Why minimum spanning trees are unchanged:
Every spanning tree of a connected n-vertex graph has exactly n-1 edges. If a constant α>0 is added to every edge weight then the total weight of any spanning tree increases by α(n-1), the same amount for every spanning tree. Therefore comparisons of total tree weights are unchanged and any tree that was an MST before the update remains an MST after the update.
Why shortest paths can change:
The length of a path with k edges increases by kα when α is added to every edge. Different s–t paths can have different numbers of edges, so adding α can change which path has the smallest total weight. In short, paths with more edges are penalised more heavily after the update.
Counterexample: vertices s, a, t with weights s–a = 1, a–t = 1, s–t = 3. Before adding α the path s→a→t has length 2 and is a shortest path. Choose α = 2. After adding α the weights are s–a = 3, a–t = 3, s–t = 5; the path s→a→t now has length 6 while the direct edge s–t has length 5, so the shortest path between s and t has changed.
Conclusion: The correct description is that MSTs remain MSTs under adding a constant to every edge, but shortest paths need not remain shortest paths.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q104.GATE 2025
A meld operation on two instances of a data structure combines them into one single instance of the same data structure. Consider the following data structures:
P: Unsorted doubly linked list with pointers to the head node and tail node of the list.
Q: Min-heap implemented using an array.
R: Binary Search Tree.
Which ONE of the following options gives the worst-case time complexities for meld operation on instances of size 𝑛 of these data structures?
- A.
P: Θ(1), Q: Θ(𝑛), R: Θ(𝑛)
- B.
P: Θ(1), Q: Θ(𝑛 log 𝑛), R: Θ(𝑛)
- C.
P: Θ(𝑛), Q: Θ(𝑛 log 𝑛), R: Θ(𝑛2)
- D.
P: Θ(1), Q: Θ(𝑛), R: Θ(𝑛 log 𝑛)
Correct answer: A
Solution
Final answer: P: Θ(1), Q: Θ(n), R: Θ(n).
P (unsorted doubly linked list with head and tail pointers): Meld by linking the tail of the first list to the head of the second and updating head/tail pointers (and handling empty lists). This is a constant number of pointer updates, so Θ(1).
Q (min-heap implemented using an array): Concatenate the two underlying arrays into one array of size 2n and run build-heap (heapify) on the combined array. Heapify runs in linear time in the array size, so the cost is Θ(2n)=Θ(n). (Note: inserting elements one-by-one would be Θ(n log n), but that is not the optimal meld algorithm.)
R (binary search tree): Perform inorder traversal of each tree to produce two sorted lists (Θ(n)), merge the two sorted lists into one sorted list (Θ(n)), and build a BST from the merged sorted list (Θ(n)). Totals to Θ(n). (A naive approach inserting nodes one-by-one into an unbalanced tree could be Θ(n^2), but the optimal melding procedure is linear.)
Therefore the worst-case time complexities for optimal meld procedures are:
Unsorted doubly linked list with head/tail pointers: Θ(1)
Min-heap in array: Θ(n)
Binary search tree: Θ(n)
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q105.GATE 2025
For a direct-mapped cache, 4 bits are used for the tag field and 12 bits are used to index into a cache block. The size of each cache block is one byte. Assume that there is no other information stored for each cache block.
Which ONE of the following is the CORRECT option for the sizes of the main memory and the cache memory in this system (byte addressable), respectively?
- A.
64 KB and 4 KB
- B.
128 KB and 16 KB
- C.
64 KB and 8 KB
- D.
128 KB and 6 KB
Correct answer: A
Solution
Key breakdown of address fields: tag bits = 4, index bits = 12, block offset bits = log2(block size) = log2(1) = 0.
Main memory size: total address bits = 4 + 12 + 0 = 16, so main memory = 2^16 bytes = 65,536 bytes = 64 KB.
Cache size (data only):
Number of cache lines = 2^index = 2^12 = 4096.
Each line stores one byte, so cache data size = 4096 × 1 B = 4096 B = 4 KB.
Note on tags and other metadata: the question specifies that no other information is stored per cache block, so we report the data-only cache size. If tag bits were to be stored in the cache, tag storage would be 4096 lines × 4 bits = 16,384 bits = 2048 bytes = 2 KB, and the total including tags would be 4 KB + 2 KB = 6 KB.
Final answer: main memory = 64 KB, cache memory = 4 KB.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q106.GATE 2025
Given a Context-Free Grammar 𝐺 as follows:
𝑆 → 𝐴𝑎 | 𝑏𝐴𝑐 | 𝑑𝑐 | 𝑏𝑑𝑎
𝐴 → 𝑑
Which ONE of the following statements is TRUE?
- A.
𝐺 is neither LALR(1) nor SLR(1)
- B.
𝐺 is CLR(1), not LALR(1)
- C.
𝐺 is LALR(1), not SLR(1)
- D.
𝐺 is LALR(1), also SLR(1)
Correct answer: C
Solution
Classification result: The grammar is LALR(1), not SLR(1).
Reasoning and key steps:
Grammar productions: S → A a | b A c | d c | b d a ; A → d.
Compute FOLLOW(A): A appears in S → A a and S → b A c, so FOLLOW(A) = {a, c}.
Why SLR(1) fails: consider the LR(0) state reached after reading a single terminal d. That state contains the items S → d · c and A → d ·. Under SLR(1) a reduction A → d is allowed on any lookahead in FOLLOW(A), including c. On lookahead c the parser therefore has both a shift action (for S → d c) and a reduction action (for A → d), producing a shift–reduce conflict. Hence the grammar is not SLR(1).
Why LR(1)/LALR(1) succeed: canonical LR(1) attaches lookaheads to items, distinguishing the two contexts where A → d completes. One LR(1) item for A → d occurs with lookahead c (when coming from S → d c) and another with lookahead a (when coming from b d a). These contexts do not introduce a conflicting action in LR(1).
LALR(1) merges LR(1) states that have identical LR(0) cores. In this grammar the LR(1) states completing A → d do not have identical cores with conflicting lookaheads, so LALR(1) does not introduce a conflict and the grammar remains parsable by an LALR(1) parser.
Conclusion: the correct statement is the one that says the grammar is LALR(1) but not SLR(1). Note that the original answer flag in the question incorrectly marked the statement that the grammar is both LALR(1) and SLR(1) as correct; that mark is wrong given the SLR(1) conflict explained above.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q107.GATE 2025
An array 𝐴 of length 𝑛 with distinct elements is said to be bitonic if there is an index 1 ≤ 𝑖 ≤ 𝑛 such that 𝐴[1. . 𝑖] is sorted in the non-decreasing order and 𝐴[𝑖 + 1 . . 𝑛] is sorted in the non-increasing order.
Which ONE of the following represents the best possible asymptotic bound for the worst-case number of comparisons by an algorithm that searches for an element in a bitonic array 𝐴?
- A.
Θ(𝑛)
- B.
Θ(1)
- C.
Θ(log2𝑛)
- D.
Θ(log 𝑛)
Correct answer: D
Solution
Answer: Θ(log n).
Reasoning (high level): find the peak element using binary search, then binary-search for the target in the increasing side and in the decreasing side.
Find the peak (index of the maximum) in O(log n): at each step check A[mid] and A[mid+1]; if A[mid] < A[mid+1] the peak is to the right, otherwise it is to the left. This halves the search interval each time.
Binary-search the increasing subarray [1..peak] for the target in O(log n): use standard binary search comparisons because this part is sorted in non-decreasing order.
Binary-search the decreasing subarray [peak+1..n] for the target in O(log n): use modified binary search that accounts for decreasing order (flip comparison directions).
Total cost: O(log n) to find the peak plus O(log n) for searches on each side. These add up to O(log n) overall, so the best possible asymptotic bound is Θ(log n).
Optimality note: this bound is tight because we provide an O(log n) algorithm and comparison-based searching among ordered sequences has an Ω(log n) decision-tree lower bound, so the asymptotic complexity is Θ(log n).
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q108.GATE 2025
Let ℱ be the set of all functions from {1, … , 𝑛} to {0,1}. Define the binary relation ≼ on ℱ as follows:
∀𝑓, 𝑔 ∈ ℱ, 𝑓 ≼ 𝑔 if and only if ∀𝑥 ∈ {1, … , 𝑛}, 𝑓(𝑥) ≤ 𝑔(𝑥), where 0 ≤ 1.
Which of the following statement(s) is/are TRUE?
- A.
≼ is a symmetric relation
- B.
(ℱ, ≼ ) is a partial order
- C.
(ℱ, ≼ ) is a lattice
- D.
≼ is an equivalence relation
Correct answer: B, C
Solution
Concept
A relation ≼ on a set S is a partial order when it is reflexive, antisymmetric, and transitive; the pair (S, ≼) is then a poset. A poset (S, ≼) is a lattice when every pair a, b ∈ S has both a meet a∧b (greatest lower bound) and a join a∨b (least upper bound) that lie in S. An equivalence relation additionally requires symmetry — a genuine order relation with more than one comparable pair can never also be symmetric, since symmetry together with antisymmetry would force every comparable pair to be equal.
Application to this relation
Each function f ∈ ℱ can be read as a bit-string of length n (its values at 1,…,n), and f ≼ g compares these bit-strings coordinate by coordinate — this is exactly the product (coordinate-wise) order on {0,1}ⁿ.
Reflexive — f(x) ≤ f(x) holds at every x, so f ≼ f for every f.
Antisymmetric — if f ≼ g and g ≼ f then f(x) ≤ g(x) and g(x) ≤ f(x) at every x, forcing f(x) = g(x) everywhere, so f = g.
Transitive — if f ≼ g and g ≼ h then f(x) ≤ g(x) ≤ h(x) at every x, so f ≼ h.
Symmetric? — Take f with f(1)=0 and g with g(1)=1, agreeing elsewhere: f ≼ g holds, but g ≼ f fails at x=1. So ≼ is NOT symmetric, and therefore NOT an equivalence relation either.
Lattice? — Define (f∧g)(x) = min(f(x), g(x)) and (f∨g)(x) = max(f(x), g(x)); both are functions in ℱ and are respectively the greatest lower bound and least upper bound of f and g under ≼. Every pair has both, so (ℱ, ≼) is a lattice.
Cross-check with n = 2
Represent the four functions as bit-strings 00, 01, 10, 11 (values at x=1,2). Then 00 ≼ 01 ≼ 11 and 00 ≼ 10 ≼ 11, while 01 and 10 are incomparable (01 ⋠ 10 and 10 ⋠ 01) — exactly the diamond-shaped Hasse diagram of the Boolean lattice B₂. Their meet is 00 (coordinate-wise min) and their join is 11 (coordinate-wise max), both present in the set, confirming the lattice property independently of the general argument above; the incomparability of 01 and 10 again confirms ≼ is not symmetric (it is not even a total order).
Conclusion
(ℱ, ≼) is a partial order and (ℱ, ≼) is a lattice; the relation is not symmetric, so it is not an equivalence relation.
- A.
- Q109.GATE 2025
Given the following Karnaugh Map for a Boolean function 𝐹(𝑤, 𝑥, 𝑦, 𝑧):

Which one or more of the following Boolean expression(s) represent(s) 𝐹?
- A.
\(\bar{w} \bar{x} \bar{y} \bar{z}+w \bar{x} \bar{y} \bar{z}+\bar{w} \bar{x} y \bar{z}+w \bar{x} y \bar{z}+x z\) - B.
\(\bar{w} \bar{x} \bar{y} \bar{z}+\bar{w} \bar{x} y \bar{z}+w \bar{x} y z+x z\) - C.
\(\bar{w} \bar{x} \bar{y} \bar{z}+w \bar{x} \bar{y} \bar{z}+w \bar{x} \bar{y} z+x z\) - D.
\(\bar{x} \bar{z}+x z\)
Correct answer: A, D
Solution
Step 1: Find groups of 1s on the Karnaugh map and identify common variables.
Group of four covering cells where x = 0 and z = 0 (w and y vary): these four minterms are \bar{w}\bar{x}\bar{y}\bar{z}, w\bar{x}\bar{y}\bar{z}, \bar{w}\bar{x}y\bar{z}, w\bar{x}y\bar{z} which simplify to \bar{x}\bar{z}.
Group of four covering cells where x = 1 and z = 1 (w and y vary): these minterms combine to x z.
Step 2: Write the simplified function by OR-ing the group results.
F(w,x,y,z) = \bar{x}\bar{z} + x z
Note: The expanded expression \bar{w}\bar{x}\bar{y}\bar{z} + w\bar{x}\bar{y}\bar{z} + \bar{w}\bar{x}y\bar{z} + w\bar{x}y\bar{z} + x z is algebraically equivalent to \bar{x}\bar{z} + x z because the four minterms shown collapse to \bar{x}\bar{z}.
Tip: To check any proposed expression, expand it into minterms and verify each minterm against the 1-cells of the K-map; any minterm present in the expression must correspond to a 1-cell, and every 1-cell must be covered by at least one term.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q110.GATE 2025
Consider a system of linear equations
\(𝑃𝑋 = 𝑄\)where\(𝑃 ∈ ℝ^{3×3}\)and\(Q ∈ ℝ^{3×1}\). Suppose\(P\)has an\(LU\)decomposition,\(𝑃 = 𝐿𝑈\), where
Which of the following statement(s) is/are TRUE?
- A.
The system
\(𝑃𝑋 = 𝑄\)can be solved by first solving\(𝐿𝑌 = 𝑄\)and then\(𝑈𝑋 = 𝑌\). - B.
If
\(P\)is invertible, then both\(L\)and\(U\)are invertible. - C.
If
\(P\)is singular, then at least one of the diagonal elements of\(U\)is zero. - D.
If
\(P\)is symmetric, then both\(L\)and\(U\)are symmetric.
Correct answer: A, B, C
Solution
Summary of which statements are true and why:
The statement that the system can be solved by first solving the lower triangular system and then the upper triangular system is true. Given P = L U and P X = Q, set Y = U X. Then L Y = Q, which is solved by forward substitution, and then U X = Y is solved by backward substitution.
The statement that if P is invertible then both L and U are invertible is true. Because L is unit lower triangular, det(L)=1 so L is invertible. Since det(P)=det(L)·det(U)=det(U), det(P)≠0 implies det(U)≠0, so U is invertible.
The statement that if P is singular then at least one diagonal element of U is zero is true. If P is singular then det(P)=0. With det(L)=1, det(P)=det(U), so det(U)=0. For a triangular matrix, det(U) is the product of its diagonal entries, hence at least one diagonal entry must be zero.
The statement that if P is symmetric then both L and U are symmetric is false. Symmetry of P does not force L and U from a general LU factorization to be symmetric. Only in special factorizations for symmetric positive definite matrices (Cholesky) do we get a lower triangular factor whose transpose is the upper factor. A general symmetric matrix can have an LU factorization where L and U are not symmetric.
Final conclusion: The first, second, and third statements are true; the fourth statement is false.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q111.GATE 2025
Consider a stack data structure into which we can PUSH and POP records. Assume that each record pushed in the stack has a positive integer key and that all keys are distinct.
We wish to augment the stack data structure with an 𝑂(1) time MIN operation that returns a pointer to the record with smallest key present in the stack
1) without deleting the corresponding record, and
2) without increasing the complexities of the standard stack operations.
Which one or more of the following approach(es) can achieve it?
- A.
Keep with every record in the stack, a pointer to the record with the smallest key below it.
- B.
Keep a pointer to the record with the smallest key in the stack.
- C.
Keep an auxiliary array in which the key values of the records in the stack are maintained in sorted order.
- D.
Keep a Min-Heap in which the key values of the records in the stack are maintained.
Correct answer: A
Solution
Suggested solution: Keep with every record in the stack a pointer to the record with the smallest key among that record and all records below it.
Push (O(1)): Create the new record. If the stack is empty, set the new record's min-pointer to itself. Otherwise compare the new record's key with the min key pointed to by the current top's min-pointer and set the new record's min-pointer to the record with the smaller key. Push the new record onto the stack.
Pop (O(1)): Remove the top record. No other updates are required because each remaining record already stores the correct min-pointer for the substack below it.
Min (O(1)): Return the min-pointer stored at the top record (or null if the stack is empty).
Complexity: PUSH, POP, and MIN all run in O(1) time. Extra space is one pointer per record (O(n)).
Why the other approaches fail:
Keeping only a single pointer to the current minimum: If the minimum element is popped, finding the new minimum requires scanning the stack (O(n)), so POP would not be O(1).
Maintaining an auxiliary array in sorted order: Inserting or deleting while preserving sorted order can take O(n) time, so PUSH and/or POP would not be O(1).
Using a min-heap: Heap insertions and deletions are O(log n). Also removing an arbitrary stack element from the heap (when POP removes a non-min element) requires locating and removing that element, which incurs extra overhead. Thus stack operations would not remain O(1).
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q112.GATE 2025
Consider the following relational schema along with all the functional dependencies that hold on them.
\(R1(A, B, C, D, E): { 𝐷 → 𝐸, 𝐸𝐴 → 𝐵, 𝐸𝐵 → 𝐶} \\\)\(R2(A, B, C, D): { 𝐴 → 𝐷, 𝐴 → 𝐵, 𝐶 → 𝐴}\)Which of the following statement(s) is/are TRUE?
- A.
\(R1\)is in 3NF - B.
\(R2\)is in 3NF - C.
\(R1\)is NOT in 3NF - D.
\(R2\)is NOT in 3NF
Correct answer: C, D
Solution
Answer: Both relations are NOT in Third Normal Form (3NF).
R1(A,B,C,D,E) with FDs: D → E, EA → B, EB → C
Candidate key reasoning: {A,D} is a key because D → E gives E, then EA → B gives B, and EB → C gives C, so A,D → A,B,C,D,E.
Prime attributes: A and D (members of the candidate key).
Check FDs against 3NF: D → E fails 3NF because D is not a superkey and E is not a prime attribute. EA → B and EB → C also fail because their left sides are not superkeys and their right-hand attributes are not prime. Therefore R1 is not in 3NF.
R2(A,B,C,D) with FDs: A → D, A → B, C → A
Candidate key reasoning: C is a key because C → A and A → B,A → D yield all attributes, so C → A,B,D and hence C → A,B,D,C.
Prime attribute: C only.
Check FDs against 3NF: A → B and A → D violate 3NF because A is not a superkey and B and D are not prime attributes. C → A is fine because C is a superkey. Overall R2 is not in 3NF.
Conclusion: The true statements are the ones claiming that R1 is NOT in 3NF and R2 is NOT in 3NF.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q113.GATE 2025
\(𝑃 = \{𝑃_1, 𝑃_2, 𝑃_3, 𝑃_4\}\)consists of all active processes in an operating system.\(𝑅 = \{𝑅_1, 𝑅_2, 𝑅_3, 𝑅_4\}\)consists of single instances of distinct types of resources in the system.The resource allocation graph has the following assignment and claim edges.
Assignment edges:
\(𝑅_1 → 𝑃_1, 𝑅_2 → 𝑃_2, 𝑅_3 → 𝑃_3, 𝑅_4 → 𝑃_4\)(the assignment edge\(𝑅_1 → 𝑃_1\)means resource\(𝑅_1\)is assigned to process\(𝑃_1\), and so on for others)Claim edges:
\(𝑃_1 → 𝑅_2, 𝑃_2 → 𝑅_3, 𝑃_3 → 𝑅_1, 𝑃_2 → 𝑅_4, 𝑃_4 → 𝑅_2\)(the claim edge\(𝑃_1 → 𝑅_2\)means process\(𝑃_1\)is waiting for resource\(𝑅_2\), and so on for others)Which of the following statement(s) is/are CORRECT?
- A.
Aborting
\(P_1\)makes the system deadlock free. - B.
Aborting
\(P_3\)makes the system deadlock free. - C.
Aborting
\(P_2\)makes the system deadlock free. - D.
Aborting
\(P_1\)and\(𝑃_4\)makes the system deadlock free.
Correct answer: C, D
Solution
Summary: The system has deadlocks represented by cycles in the resource-allocation graph. Correct answers are: aborting P2, and aborting both P1 and P4 (both choices make the system deadlock free). Aborting only P1 or only P3 does not remove all deadlocks.
Identify cycles:
Cycle 1: P1 requests R2 (held by P2) → P2 requests R3 (held by P3) → P3 requests R1 (held by P1).
Cycle 2: P2 requests R4 (held by P4) → P4 requests R2 (held by P2).
Effect of aborting each process:
Aborting P1: frees R1 and breaks Cycle 1, but Cycle 2 (between P2 and P4) remains, so the system is not deadlock free.
Aborting P3: frees R3 and breaks Cycle 1, but Cycle 2 (between P2 and P4) remains, so the system is not deadlock free.
Aborting P2: removes the common process in both cycles and frees R2. P4 can then obtain R2 and proceed, which frees R4; once R4 (and R3 after P3 proceeds) are available the other processes can complete. Therefore aborting P2 breaks all cycles and makes the system deadlock free.
Aborting both P1 and P4: frees R1 and R4, which breaks both Cycle 1 and Cycle 2. After those resources are released, the remaining processes can obtain needed resources and make progress. This is a correct (but not minimal) way to remove all deadlocks.
Final answer:
Aborting P2 makes the system deadlock free.
Aborting both P1 and P4 also makes the system deadlock free.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q114.GATE 2025
Three floating point numbers 𝑋, 𝑌, and 𝑍 are stored in three registers RX, RY, and RZ, respectively in IEEE 754 single precision format as given below in hexadecimal:
RX = 0xC1100000, RY = 0x40C00000, and RZ = 0x41400000
Which of the following option(s) is/are CORRECT?
- A.
4(𝑋 + 𝑌) + 𝑍 = 0
- B.
2𝑌 – 𝑍 = 0
- C.
4𝑋 + 3𝑍 = 0
- D.
𝑋 + 𝑌 + 𝑍 = 0
Correct answer: A, B, C
Solution
Convert the hex values to decimal (IEEE 754 single precision):
RX = 0xC1100000 → -9.0
RY = 0x40C00000 → 6.0
RZ = 0x41400000 → 12.0
Evaluate each equation using X = -9.0, Y = 6.0, Z = 12.0:
4(X + Y) + Z = 4(-9 + 6) + 12 = 4(-3) + 12 = -12 + 12 = 0 → holds.
2Y − Z = 2 * 6 − 12 = 12 − 12 = 0 → holds.
4X + 3Z = 4 * (-9) + 3 * 12 = -36 + 36 = 0 → holds.
X + Y + Z = -9 + 6 + 12 = 9 ≠ 0 → does not hold.
Final answer:
The equations that evaluate to zero are 4(X + Y) + Z = 0, 2Y − Z = 0, and 4X + 3Z = 0.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q115.GATE 2025
Which of the following Boolean algebraic equation(s) is/are CORRECT?
- A.
\(\overline{A}BC + A\overline{B}\,\overline{C} + \overline{A}\,\overline{B}\,\overline{C} + A\overline{B}C + ABC = BC + \overline{B}\,\overline{C} + \overline{A} \overline{B}\) - B.
\(AB + \overline{A}C + BC = AB + \overline{A}C\) - C.
\((A + C)(\overline{A} + B) = AB + \overline{A}C\) - D.
\(\overline{(A + \overline{B} + \overline{D})(C + D)(\overline{A} + C + D)(A + B + \overline{D})} = \overline{A}D + \overline{C} \overline{D}\)
Correct answer: B, C, D
Solution
Summary of which equalities hold:
The expression A'BC + AB'C' + A'B'C' + AB'C + ABC simplifies to AC + BC + B'C', so the provided right-hand side BC + B'C' + A'B is not equivalent.
AB + A' C + BC simplifies to AB + A' C (BC is a redundant consensus term), so the equality holds.
(A + C)(A' + B) expands to AB + A' C + BC, which reduces to AB + A' C, so the equality holds.
The complement of (A + B' + D')(C + D)(A' + C + D)(A + B + D') simplifies via De Morgan and reduction to A' D + C' D', so the equality holds.
Detailed derivations:
Simplify A'BC + AB'C' + A'B'C' + AB'C + ABC:
Group terms with C: C(A'B + AB' + AB) = C(A + B) = AC + BC. The remaining terms are B'C'. Therefore the whole expression equals AC + BC + B'C'.
Conclusion: the stated right-hand side BC + B'C' + A'B is not equivalent; a counterexample is A=1, B=0, C=1, which gives left = 1 but the stated right-hand side = 0.
Simplify AB + A' C + BC:
Use the consensus theorem: XY + X'Z + YZ = XY + X'Z. Here X=A, Y=B, Z=C. So AB + A' C + BC = AB + A' C.
Simplify (A + C)(A' + B):
Expand: (A + C)(A' + B) = AA' + AB + CA' + CB = AB + A' C + BC. Apply consensus to drop BC and obtain AB + A' C, matching the right-hand side.
Simplify the complement expression:
Apply De Morgan: the complement of a product is the OR of the complements of each factor. The factor complements are:
(A + B' + D')' = A' B D
(C + D)' = C' D'
(A' + C + D)' = A C' D'
(A + B + D')' = A' B' D
OR these terms: A' B D + C' D' + A C' D' + A' B' D. Combine A' B D + A' B' D = A' D, and note C' D' already covers A C' D'. The result is A' D + C' D', matching the stated right-hand side.
Final correct equalities (the expressions that are valid equalities):
AB + A' C + BC = AB + A' C
(A + C)(A' + B) = AB + A' C
( (A + B' + D')(C + D)(A' + C + D)(A + B + D') )' = A' D + C' D'
Note: The originally marked correct option (the long five-term sum equated to BC + B'C' + A'B) is incorrect as shown above.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q116.GATE 2025
Consider two grammars 𝐺1 and 𝐺2 with the production rules given below:
𝐺1: 𝑆 → 𝑖𝑓 𝐸 𝑡ℎ𝑒𝑛 𝑆 | 𝑖𝑓 𝐸 𝑡ℎ𝑒𝑛 𝑆 𝑒𝑙𝑠𝑒 𝑆 | 𝑎
𝐸 → 𝑏
𝐺2: 𝑆 → 𝑖𝑓 𝐸 𝑡ℎ𝑒𝑛 𝑆 | 𝑀
𝑀 → 𝑖𝑓 𝐸 𝑡ℎ𝑒𝑛 𝑀 𝑒𝑙𝑠𝑒 𝑆 | 𝑐
𝐸 → 𝑏
where 𝑖𝑓,𝑡ℎ𝑒𝑛,𝑒𝑙𝑠𝑒, 𝑎, 𝑏, 𝑐 are the terminals. Which of the following option(s) is/are CORRECT?
- A.
𝐺1 is not 𝐿𝐿(1) and 𝐺2 is 𝐿𝐿(1).
- B.
𝐺1 is 𝐿𝐿(1) and 𝐺2 is not 𝐿𝐿(1).
- C.
𝐺1 and 𝐺2 are not 𝐿𝐿(1).
- D.
𝐺1 and 𝐺2 are ambiguous.
Correct answer: C, D
Solution
C: Both not LL(1)
G₁: Common prefix if E then S in two S-productions → FIRST overlap on if.
G₂: S-productions if E then S and M (FIRST(M) includes if) → overlap on if.
D: Both ambiguous
G₁: Classic dangling else (e.g., if b then if b then a else a has 2 parse trees).
G₂: Similar recursive structure allows multiple if-else pairings for same string.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q117.GATE 2025
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)?
- A.
{𝑎𝑚𝑏𝑛 | 𝑚, 𝑛 ≥ 0}
- B.
{𝑎, 𝑏}∗ ∩ {𝑎𝑚𝑏𝑛 𝑐𝑚−𝑛 | 𝑚 ≥ 𝑛 ≥ 0}
- C.
{𝑤 | 𝑤 ∈ {𝑎, 𝑏}∗ , #𝑎 (𝑤) ≡ 2 (mod 7), and #𝑏 (𝑤) ≡ 3 (mod 9)}
- D.
{𝑤 | 𝑤 ∈ {𝑎, 𝑏}∗ , #𝑎 (𝑤) ≡ 2 (mod 7), and #𝑎 (𝑤) = #𝑏(𝑤)}
Correct answer: A, C
Solution
Answer: The regular languages among the choices are {a^m b^n | m, n ≥ 0} and { w ∈ {a,b}* | #a(w) ≡ 2 (mod 7) and #b(w) ≡ 3 (mod 9) }.
{a^m b^n | m, n ≥ 0} is regular because it equals the regular expression a*b*. A DFA can be built with a start/accepting state that loops on a, transitions on the first b to a second accepting state that loops on b; any string of a's followed by b's is accepted.
The set of strings where #a ≡ 2 (mod 7) and #b ≡ 3 (mod 9) is regular because only residues modulo fixed integers are constrained. A finite automaton can track (#a mod 7, #b mod 9) with at most 7×9 = 63 states and accept precisely the states with residues (2,3).
Intersecting {a,b}* with {a^m b^n c^{m−n} | m ≥ n ≥ 0} removes any strings containing c, forcing m−n = 0 and yielding {a^m b^m | m ≥ 0}. This language is a classic non-regular language (can be shown by the pumping lemma), so the intersection is not regular.
The language requiring #a ≡ 2 (mod 7) together with #a = #b remains non-regular because equality of the number of a's and b's is a non-regular property. Adding a modular constraint on #a does not remove the need for unbounded counting, so the language is non-regular (again, the pumping lemma can be used to prove this).
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q118.GATE 2025
Consider the database transactions T1 and T2, and data items X and Y. Which of the schedule(s) is/are conflict serializable?


- A.
R1(X), W2(X), W1(Y), W2(Y), R1(X), W1(X), COMMIT(T2), COMMIT(T1)
- B.
W2(X), R1(X), W2(Y), W1(Y), R1(X), COMMIT(T2), W1(X), COMMIT(T1)
- C.
R1(X), W1(Y), W2(X), W2(Y), R1(X), W1(X), COMMIT(T1), COMMIT(T2)
- D.
W2(X), R1(X), W1(Y), W2(Y), R1(X), COMMIT(T2), W1(X), COMMIT(T1)
Correct answer: B
Solution
Answer: Only the schedule "W2(X), R1(X), W2(Y), W1(Y), R1(X), COMMIT(T2), W1(X), COMMIT(T1)" is conflict serializable (equivalent to executing the second transaction before the first).
Method (precedence graph):
Create a node for each transaction and add a directed edge from transaction A to transaction B whenever an operation of A on a data item precedes a conflicting operation of B on the same data item (read–write, write–read, or write–write). If the graph has a cycle, the schedule is not conflict serializable; if it is acyclic, the topological order gives an equivalent serial schedule.
Apply this to each schedule:
Schedule: R1(X), W2(X), W1(Y), W2(Y), R1(X), W1(X), COMMIT(T2), COMMIT(T1) — Conflicts produce edges both from the first transaction to the second (R1(X) before W2(X), W1(Y) before W2(Y)) and from the second to the first (W2(X) before the later R1(X)). The edges form a cycle, so not conflict serializable.
Schedule: W2(X), R1(X), W2(Y), W1(Y), R1(X), COMMIT(T2), W1(X), COMMIT(T1) — All conflicts go from the second transaction to the first (writes by the second precede reads/writes by the first). The precedence graph is acyclic, so this schedule is conflict serializable and equivalent to running the second transaction before the first.
Schedule: R1(X), W1(Y), W2(X), W2(Y), R1(X), W1(X), COMMIT(T1), COMMIT(T2) — There is a read–write conflict R1(X) before W2(X) (edge from the first to the second) and later a write–read conflict W2(X) before a later R1(X) (edge from the second to the first). Those opposing edges create a cycle, so not conflict serializable.
Schedule: W2(X), R1(X), W1(Y), W2(Y), R1(X), COMMIT(T2), W1(X), COMMIT(T1) — The write of X by the second before the read by the first gives an edge from the second to the first, while the write of Y by the first before the write by the second gives an edge from the first to the second. Those two edges form a cycle, so not conflict serializable.
Conclusion: Only the schedule where the second transaction's writes on X and Y occur before the first transaction's reads and writes (the schedule beginning with W2(X), R1(X), W2(Y), W1(Y), ...) is conflict serializable; all other given interleavings produce cycles in the precedence graph.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q119.GATE 2025
Consider the following relational schema:
Students (rollno: integer, name: string, age: integer, cgpa: real)
Courses (courseno: integer, cname: string, credits: integer)
Enrolled (rollno: integer, courseno: integer, grade: string)
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?
- A.
SELECT S.name
FROM Students S
WHERE EXISTS (SELECT * FROM Enrolled E
WHERE E.courseno = 1470
AND E.rollno = S.rollno); - B.
SELECT S.name
FROM Students S
WHERE SIZEOF (SELECT * FROM Enrolled E
WHERE E.courseno = 1470
AND E.rollno = S.rollno) > 0; - C.
SELECT S.name
FROM Students S
WHERE 0 < (SELECT COUNT(*)
FROM Enrolled E
WHERE E.courseno = 1470
AND E.rollno = S.rollno); - D.
SELECT S.name
FROM Students S NATURAL JOIN Enrolled E
WHERE E.courseno = 1470;
Correct answer: A, C, D
Solution
Answer: the following queries retrieve the student names enrolled in course number 1470.
SELECT S.name FROM Students S WHERE EXISTS (SELECT * FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno);
SELECT S.name FROM Students S WHERE 0 < (SELECT COUNT(*) FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno);
SELECT S.name FROM Students S NATURAL JOIN Enrolled E WHERE E.courseno = 1470;
Preferred explicit join form (clear and safe): SELECT S.name FROM Students S JOIN Enrolled E ON S.rollno = E.rollno WHERE E.courseno = 1470;
Explanation:
The EXISTS correlated subquery works because it checks for the existence of at least one Enrolled row with the same roll number and the given courseno; it returns true as soon as a match is found.
The COUNT(*) correlated subquery is also valid: it counts matching Enrolled rows for each student, and the outer WHERE selects students with a count greater than zero. It produces the same result but may be less efficient because it computes counts rather than stopping at the first match.
The NATURAL JOIN version returns the same students because NATURAL JOIN matches on the common rollno column. It is syntactically valid, but NATURAL JOIN can be fragile if schemas change; using an explicit JOIN ... ON is clearer and safer.
The form using SIZEOF is not standard SQL. Use COUNT(*) or EXISTS instead.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q120.GATE 2025
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)
Correct answer: 4
Solution
Key formula: Average Memory Access Time (AMAT) = L1 access time + L1 miss rate × L1 miss penalty
Here, the L1 miss penalty equals the time to access L2 plus the additional cost if L2 misses (i.e., fetching from main memory). So:
L1 access time = 1 ns
L1 miss rate = 1 - 0.90 = 0.10
L2 access time (penalty when L2 hits) = 10 ns
L2 miss rate = 1 - 0.80 = 0.20
Main memory penalty (on L2 miss) = 100 ns
Compute L1 miss penalty:
L1 miss penalty = L2 access time + L2 miss rate × main memory penalty = 10 + 0.20 × 100 = 10 + 20 = 30 ns
Now compute AMAT:
AMAT = 1 + 0.10 × 30 = 1 + 3 = 4
Final answer (rounded to one decimal place): 4.0 ns
A video solution is available for this question — log in and enroll to watch it.
- Q121.GATE 2025
A 5-stage instruction pipeline has stage delays of 180, 250, 150, 170, and 250, respectively, in nanoseconds. The delay of an inter-stage latch is 10 nanoseconds. Assume that there are no pipeline stalls due to branches and other hazards. The time taken to process 1000 instructions in microseconds is __________ . (rounded off to two decimal places)
Correct answer: 261.04
Solution
Key data: stage delays = 180 ns, 250 ns, 150 ns, 170 ns, 250 ns; inter-stage latch delay = 10 ns; pipeline depth = 5 stages.
Compute the clock cycle time: it equals the longest stage delay plus the latch delay.
Longest stage delay = 250 ns, so clock cycle time = 250 ns + 10 ns = 260 ns.
Compute the number of cycles to complete 1000 instructions: for a k-stage pipeline, total cycles = k + N - 1.
Here, k = 5 and N = 1000, so cycles = 5 + 1000 - 1 = 1004 cycles.
Total time = number of cycles × clock cycle time = 1004 × 260 ns = 261,040 ns = 261.04 µs.
Answer: 261.04 microseconds
A video solution is available for this question — log in and enroll to watch it.
- Q122.GATE 2025
In a B+ - tree where each node can hold at most four key values, a root to leaf path consists of the following nodes:
A = (49, 77, 83, -), B = (7, 19, 33, 44), C = (20*, 22*, 25*, 26*)
The *-marked keys signify that these are data entries in a leaf.
Assume that a pointer between keys 𝑘1 and 𝑘2 points to a subtree containing keys in [𝑘1, 𝑘2), and that when a leaf is created, the smallest key in it is copied up into its parent.
A record with key value 23 is inserted into the B+ - tree.
The smallest key value in the parent of the leaf that contains 25* is __________. (Answer in integer)
Correct answer: 33
Solution
Answer: 33
Key insight: inserting 23 causes the leaf to overflow and split; the smallest key of the new right leaf is copied up, which then causes the parent to overflow and split, producing a new internal node whose smallest key is 33.
Locate the leaf: the leaf with entries 20, 22, 25, 26 lies under the parent with keys 7, 19, 33, 44, in the interval [19, 33).
Insert 23 into that leaf, producing entries 20, 22, 23, 25, 26. This exceeds the leaf capacity of 4, so the leaf splits.
Split result (typical split into 3 and 2): left leaf = [20, 22, 23], right leaf = [25, 26]. The smallest key of the right leaf, 25, is copied up into the parent as a separator.
Inserting 25 into the parent (which was 7, 19, 33, 44) creates 7, 19, 25, 33, 44, which overflows the parent (capacity 4).
Split the internal node of 5 keys by promoting the middle key (25) to the root. The original parent splits into two internal nodes: left = [7, 19], right = [33, 44].
The right internal node [33, 44] becomes the parent of the leaf [25, 26]. The smallest key value in that parent is 33.
Therefore, the smallest key value in the parent of the leaf that contains 25 is 33.
A video solution is available for this question — log in and enroll to watch it.
- Q123.GATE 2025
Consider the following algorithm someAlgo that takes an undirected graph 𝐺 as input.
someAlgo(𝐺)
1. Let 𝑣 be any vertex in 𝐺. Run BFS on 𝐺 starting at 𝑣. Let 𝑢 be a vertex in 𝐺 at maximum distance from 𝑣 as given by the BFS.
2. Run BFS on 𝐺 again with 𝑢 as the starting vertex. Let 𝑧 be the vertex at maximum distance from 𝑢 as given by the BFS.
3. Output the distance between 𝑢 and 𝑧 in 𝐺.
The output of someAlgo(𝑇) for the tree shown in the given figure is ___________. (Answer in integer)

Correct answer: 6
Solution
Key idea: in any tree, running BFS from an arbitrary vertex to find a farthest vertex u, then running BFS from u to find a farthest vertex z, returns the diameter of the tree (the maximum distance between any two vertices).
Reason why this works: in a tree, a farthest vertex found by BFS from any start is an endpoint of some longest path. A subsequent BFS from that endpoint reaches the opposite endpoint of a longest path, so the distance found is the diameter.
Apply to the given tree: identify one longest path across the tree from a leftmost leaf to a rightmost leaf. Tracing that path across the drawing visits 7 vertices and therefore has 6 edges.
Thus the algorithm outputs the distance between those two endpoints, which is 6.
Final answer: 6
A video solution is available for this question — log in and enroll to watch it.
- Q124.GATE 2025
Let Σ = {1,2,3,4}. For 𝑥 ∈ Σ∗ , let 𝑝𝑟𝑜𝑑(𝑥) be the product of symbols in 𝑥 modulo 7. We take 𝑝𝑟𝑜𝑑(𝜖) = 1, where 𝜖 is the null string.
For example, 𝑝𝑟𝑜𝑑(124) = (1 × 2 × 4) mod 7 = 1.
Define 𝐿 = {𝑥 ∈ Σ∗ | 𝑝𝑟𝑜𝑑(𝑥) = 2}.
The number of states in a minimum state DFA for 𝐿 is ___________. (Answer in integer)
Correct answer: 6
Solution
Interpretation: the DFA state after reading a string can be taken as the product of its symbols modulo 7 (with the start state equal to 1 for the empty string).
The nonzero residues modulo 7 (1 through 6) form a multiplicative group of order 6.
The alphabet contains the symbol 3, and 3 is a generator of this multiplicative group, so by multiplying by symbols from the alphabet we can reach every nonzero residue. Hence all residues 1,2,3,4,5,6 are reachable states.
We can build a DFA with one state for each residue 1..6, with start state 1 and the accepting state being residue 2.
Distinctness argument: for two distinct residues r and s, choose a string whose product equals r^{-1}·2 (which exists because every nonzero residue is reachable). Multiplying r by that product gives 2 (accept), while multiplying s gives s·r^{-1}·2 ≠ 2. Thus r and s are distinguishable.
Conclusion: the minimal DFA requires one state for each of the six nonzero residues, so the number of states is 6.
A video solution is available for this question — log in and enroll to watch it.
- Q125.GATE 2025
An application executes 6.4 × 108 number of instructions in 6.3 seconds. There are four types of instructions, the details of which are given in the table. The duration of a clock cycle in nanoseconds is _________. (rounded off to one decimal place)
\(\begin{array}{|c|c|c|} \hline\text{Instruction type} & \text{Clock cycles required per} \\& \text{instruction (CPI)} & \text{Number of instructions executed} \\ \hline\text{Branch} & \text{2} & \text{$2.25 \times 10^{8}$} \\ \hline\text{Load} & \text{5} & \text{$1.20 \times 10^{8}$} \\ \hline\text{Store} & \text{4} & \text{$1.65 \times 10^{8}$} \\ \hline\text{Arithmetic} & \text{3} & \text{$1.30 \times 10^{8}$} \\ \hline\end{array}\)Correct answer: 3
Solution
Answer: 3.0 ns
Steps:
Compute cycles used by each instruction type:
Branch: 2 cycles × 2.25 × 10^8 = 4.5 × 10^8 cycles
Load: 5 cycles × 1.20 × 10^8 = 6.0 × 10^8 cycles
Store: 4 cycles × 1.65 × 10^8 = 6.6 × 10^8 cycles
Arithmetic: 3 cycles × 1.30 × 10^8 = 3.9 × 10^8 cycles
Sum total cycles = 4.5 × 10^8 + 6.0 × 10^8 + 6.6 × 10^8 + 3.9 × 10^8 = 2.10 × 10^9 cycles
Clock period = total time / total cycles = 6.3 s / 2.10 × 10^9 = 3.0 × 10^-9 s = 3.0 ns
Rounded to one decimal place: 3.0 ns
A video solution is available for this question — log in and enroll to watch it.
- Q126.GATE 2025
Consider the following C program:
#include <stdio.h>
int main(){
int a;
int arr[5] = {30, 50, 10};
int *ptr;
ptr = &arr[0] + 1;
a = *ptr;
(*ptr)++;
ptr++;
printf("%d", a + (*ptr) + arr[1]);
return 0;
}The output of the above program is ___________. (Answer in integer)
Correct answer: 111
Solution
Final output: 111
Explanation of each step:
Initial array values: arr[0] = 30, arr[1] = 50, arr[2] = 10, arr[3] = 0, arr[4] = 0.
ptr is set to &arr[0] + 1, so ptr points to arr[1].
a = *ptr assigns the value at arr[1] to a, so a = 50.
(*ptr)++ increments the value at arr[1], changing arr[1] from 50 to 51.
ptr++ advances ptr to point to arr[2], whose value is 10.
The printed expression is a + (*ptr) + arr[1] = 50 + 10 + 51 = 111.
- Q127.GATE 2025
Consider the following C program:
#include <stdio.h>
int g(int n) {
return (n + 10);
}int f(int n) {
return g(n * 2);
}int main() {
int sum, n;
sum = 0;
for (n = 1; n < 3; n++)
sum += g(f(n));
printf("%d", sum);
return 0;
}The output of the given C program is ________. (Answer in integer)
Correct answer: 46
Solution
Short answer: 46
Explanation:
g(n) returns n + 10.
f(n) calls g with n * 2, so f(n) = g(n * 2) = (n * 2) + 10 = 2n + 10.
The expression g(f(n)) equals f(n) + 10 = (2n + 10) + 10 = 2n + 20.
The loop runs for n = 1 and n = 2 (since n < 3). For n = 1, g(f(1)) = 2*1 + 20 = 22. For n = 2, g(f(2)) = 2*2 + 20 = 24.
Sum = 22 + 24 = 46, which is printed by printf.
Output: 46
A video solution is available for this question — log in and enroll to watch it.
- Q128.GATE 2025
A quadratic polynomial (𝑥 − 𝛼)(𝑥 − 𝛽) over complex numbers is said to be square invariant if (𝑥 − 𝛼)(𝑥 − 𝛽) = (𝑥 − 𝛼2 )(𝑥 − 𝛽2 ). Suppose from the set of all square invariant quadratic polynomials we choose one at random.
The probability that the roots of the chosen polynomial are equal is __________. (rounded off to one decimal place)
Correct answer: 0.5
Solution

- Q129.GATE 2025
The unit interval (0,1) is divided at a point chosen uniformly distributed over (0,1) in ℝ into two disjoint subintervals.
The expected length of the subinterval that contains 0.4 is ___________. (rounded off to two decimal places)
Correct answer: 0.7 to 0.8
Solution

- Q130.GATE 2025
Consider the following statements about the use of backpatching in a compiler for intermediate code generation:
Backpatching can be used to generate code for Boolean expression in one pass
Backpatching can be used to generate code for flow-of-control statements in one pass
Which ONE of the following options is CORRECT?
- A.
Only (I) is correct
- B.
Only (II) is correct
- C.
Both (I) and (II) are correct
- D.
Neither (I) nor (II) is correct
Correct answer: C
Solution
Backpatching is a compiler technique that handles forward references during intermediate code generation. It enables one-pass compilation for Boolean expressions and flow-of-control statements by resolving jump targets later. Consequently, both provided statements regarding backpatching capabilities are correct.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q131.GATE 2025
Consider the following pseudo-code. Which one of the following options correctly specifies the number of basic blocks and the number of instructions in the largest basic block, respectively?
L1: t1 = −1
L2: t2 = 0
L3: t3 = 0
L4: t4 = 4 t3
L5: t5 = 4 t2
L6: t6 = t5 * M
L7: t7 = t4 + t6
L8: t8 = a[t7]
L9: if t8 <= max goto L11
L10: t1 = t8
L11: t3 = t3 + 1
L12: if t3 < M goto L4
L13: t2 = t2 + 1
L14: if t2 < N goto L3
L15: max = t1- A.
6 and 6
- B.
6 and 7
- C.
7 and 7
- D.
7 and 6
Correct answer: D
Solution
Basic block leaders are the first instruction, jump targets, and instructions following jumps. Leaders include L1, L3, L4, L10, L11, and L13. This yields exactly six basic blocks. The largest block spans from L4 to the jump at L9, containing six instructions.
A video solution is available for this question — log in and enroll to watch it.
- A.
- Q132.GATE 2025
Refer to the given 3-address code sequence. This code sequence is split into basic blocks. The number of basic blocks is ________. (Answer in integer)
1001: i = 1
1002: j = 1
1003: t1 = 10 * i
1004: t2 = t1 + j
1005: t3 = 8 * t2
1006: t4 = t3 - 88
1007: a[t4] = 0.0
1008: j = j + 1
1009: if j <= 10 goto 1003
1010: i = i + 1
1011: if i <= 10 goto 1002
1012: i = 1
1013: t5 = i - 1
1014: t6 = 88 * t5
1015: a[t6] = 1.0
1016: i = i + 1
1017: if i <= 10 goto 1013
Correct answer: 6
Solution
To find the number of basic blocks, we identify all leaders in the 3-address code sequence.
Step 1: Identify Leaders
A leader is a statement that starts a basic block. Leaders include:
The first statement (line 1001)
Targets of conditional jumps (lines 1002, 1003, and 1013)
Statements immediately following jump instructions (lines 1010 and 1012)
Step 2: Count the Leaders
The leaders are at lines: 1001, 1002, 1003, 1010, 1012, and 1013.
Total count = 6 leaders, which means there are exactly 6 basic blocks.
Answer: 6
A video solution is available for this question — log in and enroll to watch it.
- Q133.GATE 2025
The number -6 can be represented as 1010 in 4-bit 2's complement representation. Which of the following is/are CORRECT 2's complement representation(s) of -6?
- A.
1000 1010 in 8-bits
- B.
1111 1010 in 8-bits
- C.
1000 0000 0000 1010 in 16-bits
- D.
1111 1111 1111 1010 in 16-bits
Correct answer: B, D
Solution
In 4-bit two's complement, -6 is represented as 1010. When a negative two's complement number is extended to more bits, sign extension is used: copy the sign bit 1 into all new higher-order positions. Therefore, the 8-bit representation is 1111 1010, so option B is correct. Similarly, the 16-bit representation is 1111 1111 1111 1010, so option D is correct. Options A and C do not correctly sign-extend the 4-bit representation.
- A.