π
GATE CS - Previous Year Questions
Actual GATE CS exam questions from previous years (2020-2025)
142 questionsΓ’β¬Β’15 pagesΓ’β¬Β’~213 min
Use this quiz track to strengthen recall, speed, and exam-style decision making. Attempt one page first, review explanations, and then re-attempt incorrect questions without notes.
A good scoring strategy is to mark uncertain questions, finish known ones quickly, and return with elimination logic. This improves accuracy while keeping momentum under time constraints.
Progress: 0 / 1420%
Page 15 of 15 β’ Questions 141-142 of 142
Q141medium
[GATE CS 2024 Set-2 Q41] Let π be the 5-state NFA with π-transitions shown in the diagram below. Which one of the following regular expressions represents the language accepted by π ?
Q142medium
[GATE CS 2024 Set-2 Q42] Consider an array X that contains n positive integers. A subarray of X is defined to be a sequence of array locations with consecutive indices. The C code snippet given below has been written to compute the length of the longest subarray of X that contains at most two distinct integers. The code has two missing expressions labelled (P) and (Q). int first=0, second=0, len1=0, len2=0, maxlen=0; for (int i=0; i < n; i++) { if (X[i] == first) { len2++; len1++; } else if (X[i] == second) { len2++; len1 = (P); second = first; } else { len2 = (Q); len1 = 1; second = first; } if (len2 > maxlen) { maxlen = len2; } first = X[i]; } Which of the following options correctly fills (P) and (Q)?
...