GATE CS
    Previous Year Papers
    Verified Solutions Included
    GATE CS 2021_Set2 Question Paper with Solutions: 65 Questions, Answer Key & Section-wise Analysis

    GATE CS 2021_Set2 previous year paper: 65 questions with answer key and detailed solutions, section-wise breakdown and free sample questions.

    65 Qs

    Total Questions

    100 Marks

    Total Marks

    0 Mins

    Duration

    +3 / -1 / 0

    Marking Scheme

    Section-wise Paper Structure

    Engineering Mathematics

    9 Qs

    14% of total marks

    Theory of Computation

    6 Qs

    9% of total marks

    Programming and Data Structures

    6 Qs

    9% of total marks

    Computer Organization and Architecture

    6 Qs

    9% of total marks

    Algorithms

    6 Qs

    9% of total marks

    Databases

    5 Qs

    8% of total marks

    Compiler Design

    5 Qs

    8% of total marks

    Quantitative Aptitude

    4 Qs

    6% of total marks

    Operating System

    4 Qs

    6% of total marks

    Digital Logic

    4 Qs

    6% of total marks

    Computer Networks

    4 Qs

    6% of total marks

    Verbal Aptitude

    2 Qs

    3% of total marks

    Spatial Aptitude

    2 Qs

    3% of total marks

    Analytical Aptitude

    2 Qs

    3% of total marks

    Free Solved Questions with Step-by-Step Solutions

    Authentic examination problems with detailed derivations and answer keys.

    Question 1
    2021 Slot Set2 PYQ
    Level 3: Exam Standard
    Consider the following sets, where :

    : Set of all matrices with entries from the set
    : Set of all functions from the set to the set

    Which of the following choice(s) is/are correct?
    Question 2
    2021 Slot Set2 PYQ
    Level 3: Exam Standard
    Choose the correct choice(s) regarding the following propositional logic assertion :

    Question 3
    2021 Slot Set2 PYQ
    Level 2: Moderate

    For a given biased coin, the probability that the outcome of a toss is a head is 0.4. This coin is tossed 1,000 times. Let denote the random variable whose value is the number of times that head appeared in these 1,000 tosses. The standard deviation of (rounded to 2 decimal places) is __________.

    Question 4
    2021 Slot Set2 PYQ
    Level 3: Exam Standard

    Let be an arbitrary regular language accepted by a minimal DFA with states. Which one of the following languages must necessarily be accepted by a minimal DFA with states?

    Question 5
    2021 Slot Set2 PYQ
    Level 3: Exam Standard

    Let be a regular language and be a context-free language. Which of the following languages is/are context-free?

    Question 6
    2021 Slot Set2 PYQ
    Level 3: Exam Standard
    Consider the following deterministic finite automaton (DFA).

    start 0 1 0 1 0 1 0,1 0,1 0,1
    The number of strings of length 8 accepted by the above automaton is __________.
    Question 7
    2021 Slot Set2 PYQ

    Let be a binary min-heap consisting of elements implemented as an array. What is the worst case time complexity of an optimal algorithm to find the maximum element in ?

    Question 8
    2021 Slot Set2 PYQ
    Level 3: Exam Standard
    Consider the following ANSI C program.

    #include <stdio.h>
    int main(){
        int arr[4][5];
        int i, j;
        for (i=0; i<4; i++){
            for (j=0; j<5; j++){
                arr[i][j] = 10*i + j;
            }
        }
        printf("%d", *(arr[1] + 9));
        return 0;
    }

    What is the output of the above program?
    Question 9
    2021 Slot Set2 PYQ
    Level 3: Exam Standard
    Consider a complete binary tree with 7 nodes. Let denote the set of first 3 elements obtained by performing Breadth-First Search (BFS) starting from the root. Let denote the set of first 3 elements obtained by performing Depth-First Search (DFS) starting from the root.
    The value of is __________.
    Question 10
    2021 Slot Set2 PYQ
    Level 3: Exam Standard
    The format of the single-precision floating-point representation of a real number as per the IEEE 754 standard is as follows:

    signexponentmantissa
    Which one of the following choices is correct with respect to the smallest normalized positive number represented using the standard?
    Question 11
    2021 Slot Set2 PYQ
    Level 3: Exam Standard

    Consider a set-associative cache of size 2KB (1KB = bytes) with cache block size of 64 bytes. Assume that the cache is byte-addressable and a 32-bit address is used for accessing the cache. If the width of the tag field is 22 bits, the associativity of the cache is __________.

    Question 12
    2021 Slot Set2 PYQ
    Level 3: Exam Standard

    Consider a computer system with DMA support. The DMA module is transferring one 8-bit character in one CPU cycle from a device to memory through cycle stealing at regular intervals. Consider a 2 MHz processor. If 0.5% processor cycles are used for DMA, the data transfer rate of the device is __________ bits per second.

    Question 13
    2021 Slot Set2 PYQ
    Let be a connected undirected weighted graph. Consider the following two statements.

    There exists a minimum weight edge in which is present in every minimum spanning tree of .
    If every edge in has distinct weight, then has a unique minimum spanning tree.

    Which one of the following options is correct?
    Question 14
    2021 Slot Set2 PYQ
    Level 3: Exam Standard

    What is the worst-case number of arithmetic operations performed by recursive binary search on a sorted array of size ?

    Question 15
    2021 Slot Set2 PYQ
    Consider the string abbccddeee. Each letter in the string must be assigned a binary code satisfying the following properties:

    1. For any two letters, the code assigned to one letter must not be a prefix of the code assigned to the other letter.
    2. For any two letters of the same frequency, the letter which occurs earlier in the dictionary order is assigned a code whose length is at most the length of the code assigned to the other letter.

    Among the set of all binary code assignments which satisfy the above two properties, what is the minimum length of the encoded string?
    Question 16
    2021 Slot Set2 PYQ
    Consider the following statements S1 and S2 about the relational data model:

    S1: A relation scheme can have at most one foreign key.
    S2: A foreign key in a relation scheme R cannot be used to refer to tuples of R.

    Which one of the following choices is correct?
    Question 17
    2021 Slot Set2 PYQ

    A data file consisting of 1,50,000 student-records is stored on a hard disk with block size of 4096 bytes. The data file is sorted on the primary key RollNo. The size of a record pointer for this disk is 7 bytes. Each student-record has a candidate key attribute called ANum of size 12 bytes. Suppose an index file with records consisting of two fields, ANum value and the record pointer to the corresponding student record, is built and stored on the same disk. Assume that the records of data file and index file are not split across disk blocks. The number of blocks in the index file is __________.

    Question 18
    2021 Slot Set2 PYQ
    The relation scheme given below is used to store information about the employees of a company, where empId is the key and deptId indicates the department to which the employee is assigned. Each employee is assigned to exactly one department.

    emp(empId, name, gender, salary, deptId)

    Consider the following SQL query:

    select deptId, count(*)
    from emp
    where gender = "female" and salary > (select avg(salary) from emp)
    group by deptId;

    The above query gives, for each department in the company, the number of female employees whose salary is greater than the average salary of
    Question 19
    2021 Slot Set2 PYQ
    Level 3: Exam Standard
    Consider the following ANSI C program:

    int main() {
        Integer x;
        return 0;
    }

    Which one of the following phases in a seven-phase C compiler will throw an error?
    Question 20
    2021 Slot Set2 PYQ

    In the context of compilers, which of the following is/are NOT an intermediate representation of the source program?

    Question 21
    2021 Slot Set2 PYQ
    Consider the following ANSI C code segment:

    z = x + 3 + y->f1 + y->f2;
    for (i = 0; i < 200; i = i + 2){
        if (z > i) {
            p = p + x + 3;
            q = q + y->f1;
        } else {
            p = p + y->f2;
            q = q + x + 3;
        }
    }

    Assume that the variable y points to a struct (allocated on the heap) containing two fields f1 and f2, and the local variables x, y, z, p, q, and i are allotted registers. Common sub-expression elimination (CSE) optimization is applied on the code. The number of addition and dereference operations (of the form y->f1 or y->f2) in the optimized code, respectively, are:
    Question 22
    2021 Slot Set2 PYQ
    Level 3: Exam Standard

    If is the angle, in degrees, between the longest diagonal of the cube and any one of the edges of the cube, then,

    Question 23
    2021 Slot Set2 PYQ
    Level 3: Exam Standard

    If , then the value of is:

    Question 24
    2021 Slot Set2 PYQ
    Level 3: Exam Standard
    The number of students in three classes is in the ratio 3:13:6. If 18 students are added to each class, the ratio changes to 15:35:21.

    The total number of students in all the three classes in the beginning was:
    Question 25
    2021 Slot Set2 PYQ

    Which of the following statement(s) is/are correct in the context of CPU scheduling?

    Question 26
    2021 Slot Set2 PYQ
    Consider the following multi-threaded code segment (in a mix of C and pseudo-code), invoked by two processes P1 and P2, and each of the processes spawns two threads T1 and T2:

    int x = 0;   // global
    Lock L1;     // global
    main() {
      create a thread to execute foo();  // Thread T1
      create a thread to execute foo();  // Thread T2
      wait for the two threads to finish execution;
      print (x);}

    foo() {
      int y = 0;
      Acquire L1;
      x = x + 1;
      y = y + 1;
      Release L1;
      print (y);}

    Which of the following statement(s) is/are correct?
    Question 27
    2021 Slot Set2 PYQ
    Consider a computer system with multiple shared resource types, with one instance per resource type. Each instance can be owned by only one process at a time. Owning and freeing of resources are done by holding a global lock (L). The following scheme is used to own a resource instance :

    function OWNRESOURCE(Resource R)
        Acquire lock L // a global lock
        if R is available then
            Acquire R
            Release lock L
        else
            if R is owned by another process P then
                Terminate P, after releasing all resources owned by P
                Acquire R
                Restart P
                Release lock L
            end if
        end if
    end function

    Which of the following choice(s) about the above scheme is/are correct?
    Question 28
    2021 Slot Set2 PYQ
    Level 3: Exam Standard
    Which one of the following circuits implements the Boolean function given below?

    Question 29
    2021 Slot Set2 PYQ
    Level 3: Exam Standard

    If and are two decimal digits and , the decimal value of is __________.

    Question 30
    2021 Slot Set2 PYQ
    Level 3: Exam Standard
    Suppose we want to design a synchronous circuit that processes a string of 0’s and 1’s. Given a string, it produces another string by replacing the first 1 in any subsequence of consecutive 1’s by a 0. Consider the following example.

    Input sequence:      00100011000011100
    Output sequence:   00000001000001100

    A Mealy Machine is a state machine where both the next state and the output are functions of the present state and the current input.
    The above mentioned circuit can be designed as a two-state Mealy machine. The states in the Mealy machine can be represented using Boolean values 0 and 1. We denote the current state, the next state, the next incoming bit, and the output bit of the Mealy machine by the variables , , and respectively.
    Assume the initial state of the Mealy machine is 0.

    What are the Boolean expressions corresponding to and in terms of and ?
    Question 31
    2021 Slot Set2 PYQ

    Consider the three-way handshake mechanism followed during TCP connection establishment between hosts P and Q. Let X and Y be two random 32-bit starting sequence numbers chosen by P and Q respectively. Suppose P sends a TCP connection request message to Q with a TCP segment having SYN bit = 1, SEQ number = X, and ACK bit = 0. Suppose Q accepts the connection request. Which one of the following choices represents the information present in the TCP segment header that is sent by Q to P?

    Question 32
    2021 Slot Set2 PYQ

    Consider the cyclic redundancy check (CRC) based error detecting scheme having the generator polynomial . Suppose the message is to be transmitted. Check bits are appended at the end of the message by the transmitter using the above CRC scheme. The transmitted bit string is denoted by . The value of the checkbit sequence is

    Question 33
    2021 Slot Set2 PYQ
    Consider a computer network using the distance vector routing algorithm in its network layer. The partial topology of the network is as shown below.

    R X Y Z Q P ... ... ...
    The objective is to find the shortest-cost path from the router to routers and . Assume that does not initially know the shortest routes to and . Assume that has three neighbouring routers denoted as , , and . During one iteration, measures its distance to its neighbours , , and as 3, 2, and 5, respectively. Router gets routing vectors from its neighbours that indicate that the distance to router from routers , , and are 7, 6, and 5, respectively. The routing vector also indicates that the distance to router from routers , , and are 4, 6, and 8, respectively. Which of the following statement(s) is/are correct with respect to the new routing table of , after updation during this iteration?
    Question 34
    2021 Slot Set2 PYQ
    Level 3: Exam Standard

    Gauri said that she can play the keyboard __________ her sister.

    Question 35
    2021 Slot Set2 PYQ
    Level 3: Exam Standard
    Listening to music during exercise improves exercise performance and reduces discomfort. Scientists researched whether listening to music while studying can help students learn better and the results were inconclusive. Students who needed external stimulation for studying fared worse while students who did not need any external stimulation benefited from music.

    Which one of the following statements is the CORRECT inference of the above passage?
    Question 36
    2021 Slot Set2 PYQ
    Level 3: Exam Standard

    A transparent square sheet shown above is folded along the dotted line. The folded sheet will look like ________.
    Question 37
    2021 Slot Set2 PYQ
    Level 3: Exam Standard

    A jigsaw puzzle has 2 pieces. One of the pieces is shown above. Which one of the given options for the missing piece when assembled will form a rectangle? The piece can be moved, rotated or flipped to assemble with the above piece.
    Question 38
    2021 Slot Set2 PYQ
    Level 3: Exam Standard
    Pen : Write :: Knife : _________

    Which one of the following options maintains a similar logical relation in the above?
    Question 39
    2021 Slot Set2 PYQ
    Level 3: Exam Standard
    Six students P, Q, R, S, T and U, with distinct heights, compare their heights and make the following observations.

    Observation I: S is taller than R.

    Observation II: Q is the shortest of all.

    Observation III: U is taller than only one student.

    Observation IV: T is taller than S but is not the tallest.

    The number of students that are taller than R is the same as the number of students shorter than ______.

    Unlock All 65 Questions in Real Examination Mode

    Practice with the authentic timer, on-screen calculator, instant percentile ranking, and section-wise analytics.

    More GATE CS Previous Year Papers

    Free preview ends here

    Login to view the complete paper and solutions

    Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.

    Why MastersUp

    Personalised first. High quality throughout.

    Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.

    Built around you, not around a syllabus PDF

    Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.

    Revision that hits your weak spots

    We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.

    Questions calibrated to the real exam

    Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.

    Notes written for recall, not for volume

    Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.

    One place for everything

    Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.

    Honest progress

    No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.

    Unlock the whole course

    Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.

    GATE CS 2021_Set2 Question Paper with Solutions: 65 Questions, Answer Key & Section-wise Analysis

    GATE CS 2021_Set2 previous year paper: 65 questions with answer key and detailed solutions, section-wise breakdown and free sample questions.

    Paper breakdown

    65 questions · 100 marks. Engineering Mathematics: 9 · Theory of Computation: 6 · Programming and Data Structures: 6 · Computer Organization and Architecture: 6 · Algorithms: 6 · Databases: 5 · Compiler Design: 5 · Quantitative Aptitude: 4 · Operating System: 4 · Digital Logic: 4 · Computer Networks: 4 · Verbal Aptitude: 2 · Spatial Aptitude: 2 · Analytical Aptitude: 2

    Free sample questions from GATE CS 2021_Set2 Question Paper

    Question 1 · Engineering Mathematics · 2021_Set2 MSQ
    Consider the following sets, where :

    : Set of all matrices with entries from the set
    : Set of all functions from the set to the set

    Which of the following choice(s) is/are correct?
    1. A.

      There does not exist a bijection from to .

    2. B.

      There exists a surjection from to .

    3. C.

      There exists a bijection from to .

    4. D.

      There does not exist an injection from to .

    Correct Answer:

    ["B","C"]

    Step-by-Step Solution

    Key idea: This is a cardinality comparison question, recognizable by the need to compare the sizes of two differently described sets.

    Step 1: Calculate the cardinality of . An matrix has entries. Each entry can be independently chosen from the set , which has 3 elements. Thus, .

    Step 2: Calculate the cardinality of . The set of all functions from a domain of size to a codomain of size is . Here, the domain is , which has size . The codomain is , which has size 3. Thus, .

    Step 3: Compare the cardinalities. Since and both are finite sets, there exists a bijection between them.

    Step 4: Evaluate the options. Since a bijection exists, Option C is true. A bijection is also a surjection, so Option B is true. Options A and D are false because they claim a bijection or injection does not exist.

    Answer: Options B and C.

    Question 2 · Engineering Mathematics · 2021_Set2 MSQ
    Choose the correct choice(s) regarding the following propositional logic assertion :

    1. A.

      is neither a tautology nor a contradiction.

    2. B.

      is a tautology.

    3. C.

      is a contradiction.

    4. D.

      The antecedent of is logically equivalent to the consequent of .

    Correct Answer:

    ["B","D"]

    Step-by-Step Solution

    Key idea: This is a logical equivalence and tautology verification question, recognizable because it asks you to classify a complex implication and compare its antecedent to its consequent. The key method is to simplify both sides algebraically using the definition of implication and De Morgan's laws.

    Step 1: Identify the antecedent and consequent of .

    Let (the antecedent).

    Let (the consequent).

    Step 2: Simplify the antecedent .

    Using the definition :

    Applying De Morgan's law :

    Step 3: Simplify the consequent .

    First, simplify the inner implication :

    Now substitute back into :

    Apply the definition of implication:

    Apply De Morgan's law:

    By associativity and idempotence ():

    Step 4: Compare and .

    Both simplify to , so .

    Therefore, is of the form , which is always true.

    This means is a tautology, and the antecedent is logically equivalent to the consequent.

    Answer: B, D

    Question 3 · Engineering Mathematics · 2021_Set2 NAT

    For a given biased coin, the probability that the outcome of a toss is a head is 0.4. This coin is tossed 1,000 times. Let denote the random variable whose value is the number of times that head appeared in these 1,000 tosses. The standard deviation of (rounded to 2 decimal places) is __________.

    Correct Answer:

    15.49

    Step-by-Step Solution

    Insight: The number of heads in independent tosses of a biased coin follows a Binomial distribution .

    Exam route: Identify , , . Variance . Standard deviation .

    Learning route:

    1. Recognize the distribution: .
    2. Recall the variance formula for a Binomial random variable: .
    3. Calculate the variance: .
    4. Standard deviation is the square root of variance: .
    5. Round to two decimal places as requested: .
    Question 4 · Theory of Computation · 2021_Set2 MCQ

    Let be an arbitrary regular language accepted by a minimal DFA with states. Which one of the following languages must necessarily be accepted by a minimal DFA with states?

    1. A.

    2. B.

    3. C.

    4. D.

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: This is a state complexity and language equivalence question, recognizable because it asks about the minimal DFA state count after applying language operations.

    Step 1: Analyze the given condition. We have a minimal DFA for with exactly states.

    Step 2: Evaluate option 3 (Complementation). The complement of , denoted , is accepted by the exact same DFA structure, but with final and non-final states swapped.

    Step 3: Check minimality preservation. Two states are distinguishable in if and only if they are distinguishable in . Therefore, the swapped DFA is already minimal and has exactly states.

    Step 4: Evaluate other options. Adding or removing a finite string (Options 1 and 2) can increase the state count (e.g., if has , requires more states to explicitly reject "01"). Concatenation (Option 4) can increase state complexity up to .

    Answer:

    Question 5 · Theory of Computation · 2021_Set2 MSQ

    Let be a regular language and be a context-free language. Which of the following languages is/are context-free?

    1. A.

    2. B.

    3. C.

    4. D.

    Correct Answer:

    ["B","C","D"]

    Step-by-Step Solution

    Key idea: This question tests the closure properties of Context-Free Languages (CFLs) when combined with Regular languages using boolean operations. We must determine which expressions are guaranteed to be CFL.

    Given: is Regular, is CFL.

    Step 1: Evaluate Option A: .

    CFLs are NOT closed under complementation, so is not necessarily a CFL. The intersection of a Regular language and a non-CFL can be non-CFL.

    Counterexample: Let (Regular) and be a CFL whose complement is not CFL. Then , which is not CFL. Thus, Option A is NOT always CFL.

    Step 2: Evaluate Option B: .

    By De Morgan's Laws, this simplifies to .

    A fundamental theorem states that the intersection of a Regular language and a CFL is always a CFL. Thus, Option B is ALWAYS context-free.

    Step 3: Evaluate Option C: .

    For any language , (the set of all strings over the alphabet).

    is a Regular language (and therefore a CFL).

    The union of (Regular) and is , which is Regular, and thus always a CFL. Thus, Option C is ALWAYS context-free.

    Step 4: Evaluate Option D: .

    By the distributive law of sets, we can factor out :

    .

    Since is given as a CFL, the result is exactly , which is always a CFL. Thus, Option D is ALWAYS context-free.

    Answer: Options B, C, and D are always context-free.

    Question 6 · Theory of Computation · 2021_Set2 NAT
    Consider the following deterministic finite automaton (DFA).

    start 0 1 0 1 0 1 0,1 0,1 0,1
    The number of strings of length 8 accepted by the above automaton is __________.
    Correct Answer:

    204

    Step-by-Step Solution

    Key idea: This is a string counting problem on a DFA, recognizable by the request for the number of accepted strings of a specific length. We must analyze the state transitions to determine which strings reach the final state.

    Step 1: Analyze the DFA structure from the diagram.

    Let the states be (start), (top row), and (final, bottom right? No, let's trace carefully).

    Looking at the SVG:

    • Start arrow points to left-most state ().
    • (top middle-left), (bottom middle-left).
    • (top middle-right), (bottom middle-right).
    • , .
    • (final state, double circle).
    • .
    • (self-loop).

    Wait, let's re-read the SVG coordinates and labels carefully.

    States:

    1. Start -> Circle at (110, 136). Let's call this S.
    2. Circle at (210, 55). Let's call this A.
    3. Circle at (210, 217). Let's call this B.
    4. Circle at (350, 55). Let's call this C.
    5. Circle at (350, 217). Let's call this D.
    6. Circle at (480, 136) with inner circle (Final). Let's call this F.

    Transitions:

    • S -> A on '0'
    • S -> B on '1'
    • A -> C on '0'
    • A -> D on '1' (Arrow from 210,55 to 350,217 labeled '1')
    • B -> D on '0' (Arrow from 210,217 to 350,55? No, label is near the cross. Let's trace lines.)
    • Line from B(210,217) goes to C(350,55)? Label '0' is at (272, 164). Yes.
    • Line from B(210,217) goes to D(350,217)? Label '1' is at (275, 237). Yes.
    • So:
    • (Wait, line from B to C? The line from 210,217 to 350,55 has label '0' at 272,164. Correct.)
    • (Line from 210,217 to 350,217 has label '1' at 275,237. Correct.)
    • From C(350,55): Arrow to F(480,136) labeled '0,1'.
    • From D(350,217): Arrow to F(480,136) labeled '0,1'.
    • From F(480,136): Self loop labeled '0,1'.

    Step 2: Determine the condition for acceptance.

    To reach the final state F, a string must pass through either C or D.

    Paths to C or D have length exactly 2.

    Any string of length will reach F at step 2 and stay there due to the self-loop.

    Strings of length 0 or 1 cannot reach F.

    Therefore, the DFA accepts all strings of length .

    Step 3: Count strings of length 8.

    Total binary strings of length 8 is .

    Since all strings of length are accepted, and , all strings are accepted.

    Wait, let me double check the "trap". Is it possible that some paths don't go to F?

    C -> F on 0,1.

    D -> F on 0,1.

    Yes, once you hit layer 2 (C or D), you go to F and stay there.

    Are there any dead states? No, all transitions are defined and lead towards F or are part of the path to F.

    So .

    Number of strings of length 8 is .

    Let me re-read the diagram. Is it possible that C and D are not "layer 2"?

    S->A (len 1)

    S->B (len 1)

    A->C (len 2)

    A->D (len 2)

    B->C (len 2)

    B->D (len 2)

    Yes, all paths of length 2 end in C or D.

    From C and D, all inputs go to F.

    So any string of length 2 ends in C or D. The next character (3rd char) moves it to F.

    So strings of length 3 or more are definitely in F.

    What about strings of length exactly 2? They end in C or D. C and D are NOT final.

    So strings of length 2 are REJECTED.

    Strings of length 1 end in A or B. Rejected.

    Strings of length 0 end in S. Rejected.

    So the language is .

    Step 4: Recalculate.

    We need the number of strings of length 8.

    Since , all strings of length 8 are accepted.

    Total strings = .

    Let's check if there is any other interpretation.

    Maybe the loop on F is not a self-loop?

    "path d='M493 123 C538 78 548 166 498 145'" -> This is a loop back to F.

    Is it possible that some transitions from S, A, B go elsewhere?

    S has only 0,1 outgoing.

    A has only 0,1 outgoing.

    B has only 0,1 outgoing.

    So, any string of length 2 lands in {C, D}.

    Any string of length 3 lands in {F}.

    Any string of length > 3 stays in {F}.

    Thus, .

    For length 8, all strings are in L.

    Answer: 256.

    Let me check if I missed any "dead" transitions.

    The diagram shows all transitions accounted for.

    S: 0->A, 1->B.

    A: 0->C, 1->D.

    B: 0->C, 1->D.

    C: 0,1->F.

    D: 0,1->F.

    F: 0,1->F.

    Yes, it is a "width-2, depth-2" tree that collapses into a sink accept state.

    Depth 0: S (Reject)

    Depth 1: A, B (Reject)

    Depth 2: C, D (Reject)

    Depth 3+: F (Accept)

    So min length is 3.

    Length 8 is accepted.

    Count = .

    Question 7 · Programming and Data Structures · 2021_Set2 MCQ

    Let be a binary min-heap consisting of elements implemented as an array. What is the worst case time complexity of an optimal algorithm to find the maximum element in ?

    1. A.

    2. B.

    3. C.

    4. D.

    Question 8 · Programming and Data Structures · 2021_Set2 MCQ
    Consider the following ANSI C program.

    #include <stdio.h>
    int main(){
        int arr[4][5];
        int i, j;
        for (i=0; i<4; i++){
            for (j=0; j<5; j++){
                arr[i][j] = 10*i + j;
            }
        }
        printf("%d", *(arr[1] + 9));
        return 0;
    }

    What is the output of the above program?
    1. A.

      14

    2. B.

      20

    3. C.

      24

    4. D.

      30

    Correct Answer:

    C

    Step-by-Step Solution

    Insight: This is a multidimensional array pointer arithmetic question, recognizable by the expression *(arr[1] + 9).

    Exam route: arr[1] is an int pointing to arr[1][0]. Adding 9 moves the pointer 9 integers forward. Since each row has 5 elements, this lands on arr[1 + 1][4] = arr[2][4]. Value is 102 + 4 = 24.

    Learning route:

    1. arr is a 2D array of size 4x5, stored in contiguous row-major memory.
    2. arr[1] is the name of the second row. In an expression, it decays to a pointer to its first element, i.e., &arr[1][0]. Its type is int *.
    3. The expression arr[1] + 9 performs pointer arithmetic. It adds 9 to the int * pointer.
    4. Since each row has 5 elements, moving 5 steps forward reaches the start of the next row: arr[1] + 5 is equivalent to &arr[2][0].
    5. Moving 4 more steps reaches &arr[2][4]. Thus, arr[1] + 9 is equivalent to &arr[2][4].
    6. Dereferencing this with * gives the value of arr[2][4].
    7. The initialization rule is arr[i][j] = 10i + j. For i=2, j=4, the value is 102 + 4 = 24.
    Question 9 · Programming and Data Structures · 2021_Set2 NAT
    Consider a complete binary tree with 7 nodes. Let denote the set of first 3 elements obtained by performing Breadth-First Search (BFS) starting from the root. Let denote the set of first 3 elements obtained by performing Depth-First Search (DFS) starting from the root.
    The value of is __________.
    Correct Answer:

    1.00

    Step-by-Step Solution

    Insight: This is a tree traversal set-operation question, recognizable because it asks for the size of the set difference between the first few elements of BFS and DFS.

    Exam route: For a complete 7-node tree, BFS starts 1, 2, 3. DFS (preorder) starts 1, 2, 4. Set , Set . . Size is 1.

    Learning route:

    Step 1: Define the tree structure. A complete binary tree with 7 nodes has levels 0, 1, and 2 fully filled.

    Level 0: 1

    Level 1: 2, 3

    Level 2: 4, 5, 6, 7

    Step 2: Determine BFS order. BFS visits level by level, left to right.

    Sequence: 1, 2, 3, 4, 5, 6, 7.

    First 3 elements: .

    Step 3: Determine DFS order. Standard DFS is preorder (Node, Left, Right).

    Sequence: 1, 2, 4, 5, 3, 6, 7.

    First 3 elements: .

    Step 4: Compute set difference .

    contains elements in but not in .

    .

    Step 5: Find the cardinality. .

    Wrong path: Confusing set difference with symmetric difference , which would yield and size 2. Or assuming DFS visits right child first (yielding , , size still 1, but the reasoning is flawed).

    Question 10 · Computer Organization and Architecture · 2021_Set2 MCQ
    The format of the single-precision floating-point representation of a real number as per the IEEE 754 standard is as follows:

    signexponentmantissa
    Which one of the following choices is correct with respect to the smallest normalized positive number represented using the standard?
    1. A.

      exponent = 00000000 and mantissa = 00000000000000000000000

    2. B.

      exponent = 00000000 and mantissa = 00000000000000000000001

    3. C.

      exponent = 00000001 and mantissa = 00000000000000000000000

    4. D.

      exponent = 00000001 and mantissa = 00000000000000000000001

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: Identify the conditions for a "normalized" number in IEEE 754 single-precision format and find the minimum possible value.

    Step 1: Recall the IEEE 754 single-precision layout.

    1 bit for sign, 8 bits for exponent, 23 bits for mantissa (fraction).

    Step 2: Understand the "normalized" condition.

    A number is normalized if its exponent field is neither all 0s (00000000, which denotes zero or subnormal numbers) nor all 1s (11111111, which denotes infinity or NaN).

    Step 3: Find the smallest normalized positive number.

    • Positive: Sign bit must be 0.
    • Smallest exponent: The smallest valid exponent field for a normalized number is 00000001 (biased exponent 1, actual exponent 1 - 127 = -126).
    • Smallest mantissa: To minimize the value, the fraction bits should be as small as possible, which is all 0s (000000000000 is 23 zeros). This gives a significand of exactly 1.0.

    Step 4: Match with options.

    Exponent = 00000001 and mantissa = 00000000000000000000000.

    This corresponds to Option C.

    Question 11 · Computer Organization and Architecture · 2021_Set2 NAT

    Consider a set-associative cache of size 2KB (1KB = bytes) with cache block size of 64 bytes. Assume that the cache is byte-addressable and a 32-bit address is used for accessing the cache. If the width of the tag field is 22 bits, the associativity of the cache is __________.

    Correct Answer:

    2

    Step-by-Step Solution

    Key idea: this is a set-associative cache parameter calculation question, recognisable because it gives the total cache size, block size, address size, and tag field width, and asks to find the associativity.

    Step 1: Identify the given parameters. Cache size = 2 KB = bytes. Block size = 64 bytes = bytes. Address size = 32 bits. Tag bits = 22.

    Step 2: Calculate the number of lines in the cache. Number of lines = Cache size / Block size = lines.

    Step 3: Set up the address decomposition equation. Let be the associativity (number of lines per set).

    Number of sets = .

    Set index bits = .

    Block offset bits = .

    Step 4: Use the tag bits formula. Tag bits = Address size - Set index bits - Offset bits.

    .

    Answer: 2

    Question 12 · Computer Organization and Architecture · 2021_Set2 NAT

    Consider a computer system with DMA support. The DMA module is transferring one 8-bit character in one CPU cycle from a device to memory through cycle stealing at regular intervals. Consider a 2 MHz processor. If 0.5% processor cycles are used for DMA, the data transfer rate of the device is __________ bits per second.

    Correct Answer:

    80000

    Step-by-Step Solution

    Key idea: This is a DMA throughput calculation question, recognisable because it gives processor frequency, cycle fraction, and transfer size.

    Step 1: Calculate the total number of CPU cycles per second. The processor is 2 MHz, which is cycles/second.

    Step 2: Calculate the number of cycles used for DMA per second. This is 0.5% of the total cycles: cycles/second.

    Step 3: Relate cycles to data transferred. The problem states that 1 CPU cycle transfers one 8-bit character.

    Step 4: Calculate the total data transfer rate in bits per second. bits/second.

    Answer: 80000

    Question 13 · Algorithms · 2021_Set2 MCQ
    Let be a connected undirected weighted graph. Consider the following two statements.

    There exists a minimum weight edge in which is present in every minimum spanning tree of .
    If every edge in has distinct weight, then has a unique minimum spanning tree.

    Which one of the following options is correct?
    1. A.

      Both and are true.

    2. B.

      is true and is false.

    3. C.

      is false and is true.

    4. D.

      Both and are false.

    Question 14 · Algorithms · 2021_Set2 MCQ

    What is the worst-case number of arithmetic operations performed by recursive binary search on a sorted array of size ?

    1. A.

    2. B.

    3. C.

    4. D.

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: Recursive binary search divides the problem size by 2 in each step. The depth of the recursion tree determines the number of operations.

    Step 1: Analyze the algorithm.

    • Binary search on a sorted array of size .
    • In each recursive call, we calculate the middle index and compare the target with the middle element.
    • Based on the comparison, we recurse on either the left half or the right half.
    • The size of the problem reduces from to .

    Step 2: Formulate the recurrence.

    • Let be the number of arithmetic operations/comparisons.
    • .
    • The term accounts for calculating mid and the comparison.

    Step 3: Solve the recurrence.

    • This is a standard recurrence solved by the Master Theorem or iteration.
    • Depth of recursion = .
    • At each level, constant work is done.
    • Total operations .

    Step 4: Determine the asymptotic bound.

    • Worst-case occurs when the element is not present or is at a leaf.
    • Number of steps = .
    • This is .

    Step 5: Match with options.

    • Option B is .

    Answer: B

    Question 15 · Algorithms · 2021_Set2 MCQ
    Consider the string abbccddeee. Each letter in the string must be assigned a binary code satisfying the following properties:

    1. For any two letters, the code assigned to one letter must not be a prefix of the code assigned to the other letter.
    2. For any two letters of the same frequency, the letter which occurs earlier in the dictionary order is assigned a code whose length is at most the length of the code assigned to the other letter.

    Among the set of all binary code assignments which satisfy the above two properties, what is the minimum length of the encoded string?
    1. A.

      21

    2. B.

      23

    3. C.

      25

    4. D.

      30

    Question 16 · Databases · 2021_Set2 MCQ
    Consider the following statements S1 and S2 about the relational data model:

    S1: A relation scheme can have at most one foreign key.
    S2: A foreign key in a relation scheme R cannot be used to refer to tuples of R.

    Which one of the following choices is correct?
    1. A.

      Both S1 and S2 are true.

    2. B.

      S1 is true and S2 is false.

    3. C.

      S1 is false and S2 is true.

    4. D.

      Both S1 and S2 are false.

    Question 17 · Databases · 2021_Set2 NAT

    A data file consisting of 1,50,000 student-records is stored on a hard disk with block size of 4096 bytes. The data file is sorted on the primary key RollNo. The size of a record pointer for this disk is 7 bytes. Each student-record has a candidate key attribute called ANum of size 12 bytes. Suppose an index file with records consisting of two fields, ANum value and the record pointer to the corresponding student record, is built and stored on the same disk. Assume that the records of data file and index file are not split across disk blocks. The number of blocks in the index file is __________.

    Question 18 · Databases · 2021_Set2 MCQ
    The relation scheme given below is used to store information about the employees of a company, where empId is the key and deptId indicates the department to which the employee is assigned. Each employee is assigned to exactly one department.

    emp(empId, name, gender, salary, deptId)

    Consider the following SQL query:

    select deptId, count(*)
    from emp
    where gender = "female" and salary > (select avg(salary) from emp)
    group by deptId;

    The above query gives, for each department in the company, the number of female employees whose salary is greater than the average salary of
    1. A.

      employees in the department.

    2. B.

      employees in the company.

    3. C.

      female employees in the department.

    4. D.

      female employees in the company.

    Question 19 · Compiler Design · 2021_Set2 MCQ
    Consider the following ANSI C program:

    int main() {
        Integer x;
        return 0;
    }

    Which one of the following phases in a seven-phase C compiler will throw an error?
    1. A.

      Lexical analyzer

    2. B.

      Syntax analyzer

    3. C.

      Semantic analyzer

    4. D.

      Machine dependent optimizer

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: This is an Error Classification question. We must trace the given code through the compiler phases to see which one first flags an error.

    Step 1: Analyze the code snippet.

    The code is Integer x;. In ANSI C, Integer is not a reserved keyword (the correct keyword is int).

    Step 2: Lexical Analysis Phase.

    The lexical analyzer (scanner) reads the characters and groups them into tokens based on regular expressions. Since Integer is not a reserved keyword, the scanner treats it as a standard identifier (id).

    The token stream produced is: <id, "Integer">, <id, "x">, <;>.

    No lexical error is thrown because Integer is a perfectly valid identifier.

    Step 3: Syntax Analysis Phase.

    The syntax analyzer (parser) receives the token stream and tries to build a parse tree using the context-free grammar of C.

    A variable declaration in C requires a type specifier followed by an identifier and a semicolon (e.g., type_specifier id ;).

    The parser sees <id> <id> ;. This sequence does not match any valid production rule for a declaration or statement in the C grammar.

    Therefore, the parser fails to parse the tokens and throws a Syntax Error.

    Step 4: Semantic Analysis Phase.

    The semantic analyzer never receives this code because the compilation halts (or at least flags the primary error) at the syntax analysis phase. Even if it did, it would look for type compatibility, but the structural grammar violation is caught first.

    Answer: Syntax analyzer

    Question 20 · Compiler Design · 2021_Set2 MSQ

    In the context of compilers, which of the following is/are NOT an intermediate representation of the source program?

    1. A.

      Three address code

    2. B.

      Abstract Syntax Tree (AST)

    3. C.

      Control Flow Graph (CFG)

    4. D.

      Symbol table

    Question 21 · Compiler Design · 2021_Set2 MCQ
    Consider the following ANSI C code segment:

    z = x + 3 + y->f1 + y->f2;
    for (i = 0; i < 200; i = i + 2){
        if (z > i) {
            p = p + x + 3;
            q = q + y->f1;
        } else {
            p = p + y->f2;
            q = q + x + 3;
        }
    }

    Assume that the variable y points to a struct (allocated on the heap) containing two fields f1 and f2, and the local variables x, y, z, p, q, and i are allotted registers. Common sub-expression elimination (CSE) optimization is applied on the code. The number of addition and dereference operations (of the form y->f1 or y->f2) in the optimized code, respectively, are:
    1. A.

      403 and 102

    2. B.

      203 and 2

    3. C.

      303 and 102

    4. D.

      303 and 2

    Question 22 · Quantitative Aptitude · 2021_Set2 MCQ

    If is the angle, in degrees, between the longest diagonal of the cube and any one of the edges of the cube, then,

    1. A.

    2. B.

    3. C.

    4. D.

    Correct Answer:

    B

    Step-by-Step Solution

    Insight: The angle between a cube's body diagonal and any of its edges is a constant, independent of the cube's size.

    Exam route: Recall the standard formula for a cube: .

    Learning route:

    1. Let the cube have edge length .
    2. The body diagonal stretches from one corner to the opposite corner through the interior. Its length is .
    3. The angle between the body diagonal and an edge forms a right triangle where the edge is the adjacent side (length ) and the body diagonal is the hypotenuse (length ).
    4. Therefore, .

    Wrong path: Confusing the body diagonal with a face diagonal. A face diagonal has length , which would give (Option C). This is incorrect because the question specifies the "longest diagonal".

    Question 23 · Quantitative Aptitude · 2021_Set2 MCQ

    If , then the value of is:

    1. A.

      2

    2. B.

      4

    3. C.

      6

    4. D.

      8

    Correct Answer:

    B

    Step-by-Step Solution

    Insight: Recognize the difference of squares pattern to avoid messy expansion.

    Exam route: Let and . Then and . The equation becomes .

    Learning route:

    Expand both squares: .

    Simplify the left side: .

    Equate to the right side: .

    Subtract from both sides and add 2 to both sides: .

    Question 24 · Quantitative Aptitude · 2021_Set2 MCQ
    The number of students in three classes is in the ratio 3:13:6. If 18 students are added to each class, the ratio changes to 15:35:21.

    The total number of students in all the three classes in the beginning was:
    1. A.

      22

    2. B.

      66

    3. C.

      88

    4. D.

      110

    Correct Answer:

    C

    Step-by-Step Solution

    Insight: Adding the same constant to every term of a ratio preserves the absolute difference between terms. Use that invariant to set up a quick equation.

    Exam route: Initial ratio parts sum . After , ratio . Using first two terms: . Total .

    Learning route:

    Step 1: Let initial students be . Total .

    Step 2: After adding 18 to each class: .

    Step 3: The new ratio of the first two classes is .

    Step 4: Cross-multiply: .

    Step 5: Solve: .

    Step 6: Initial total .

    Trap warning: Option A () is just the sum of the ratio parts, forgetting the multiplier. Option B () and D () come from mis-solving the equation or mis-scaling.

    Verification: Initial . After : . Ratio . Matches.

    Question 25 · Operating System · 2021_Set2 MSQ

    Which of the following statement(s) is/are correct in the context of CPU scheduling?

    1. A.

      Turnaround time includes waiting time.

    2. B.

      The goal is to only maximize CPU utilization and minimize throughput.

    3. C.

      Round-robin policy can be used even when the CPU time required by each of the processes is not known apriori.

    4. D.

      Implementing preemptive scheduling needs hardware support.

    Question 26 · Operating System · 2021_Set2 MSQ
    Consider the following multi-threaded code segment (in a mix of C and pseudo-code), invoked by two processes P1 and P2, and each of the processes spawns two threads T1 and T2:

    int x = 0;   // global
    Lock L1;     // global
    main() {
      create a thread to execute foo();  // Thread T1
      create a thread to execute foo();  // Thread T2
      wait for the two threads to finish execution;
      print (x);}

    foo() {
      int y = 0;
      Acquire L1;
      x = x + 1;
      y = y + 1;
      Release L1;
      print (y);}

    Which of the following statement(s) is/are correct?
    1. A.

      Both P1 and P2 will print the value of x as 2.

    2. B.

      At least one of P1 and P2 will print the value of x as 4.

    3. C.

      At least one of the threads will print the value of y as 2.

    4. D.

      Both T1 and T2, in both the processes, will print the value of y as 1.

    Question 27 · Operating System · 2021_Set2 MSQ
    Consider a computer system with multiple shared resource types, with one instance per resource type. Each instance can be owned by only one process at a time. Owning and freeing of resources are done by holding a global lock (L). The following scheme is used to own a resource instance :

    function OWNRESOURCE(Resource R)
        Acquire lock L // a global lock
        if R is available then
            Acquire R
            Release lock L
        else
            if R is owned by another process P then
                Terminate P, after releasing all resources owned by P
                Acquire R
                Restart P
                Release lock L
            end if
        end if
    end function

    Which of the following choice(s) about the above scheme is/are correct?
    1. A.

      The scheme ensures that deadlocks will not occur.

    2. B.

      The scheme may lead to live-lock.

    3. C.

      The scheme may lead to starvation.

    4. D.

      The scheme violates the mutual exclusion property.

    Question 28 · Digital Logic · 2021_Set2 MCQ
    Which one of the following circuits implements the Boolean function given below?

    1. A. 4x1 Mux 1 1 x x′ 0 1 2 3 f s₁ s₀ y z
    2. B. 4x1 Mux x 1 x′ 1 0 1 2 3 f s₁ s₀ y z
    3. C. 4x1 Mux 1 1 x′ x 0 1 2 3 f s₁ s₀ y z
    4. D. 4x1 Mux x′ 1 x 1 0 1 2 3 f s₁ s₀ y z
    Correct Answer:

    A

    Step-by-Step Solution

    Insight: Use the implementation table method to map an n-variable function onto a 2^(n-1)-to-1 multiplexer by treating the MSB as a variable input.

    Exam route: Create a 2-row table with the lower-order variables (y, z) as columns. Compare the minterm values for x=0 and x=1 in each column to determine the MUX data inputs (0, 1, x, or x').

    Learning route:

    1. The function is .
    2. We are using a 4-to-1 MUX, which has 2 select lines. We assign the lower-order variables to the select lines: , . The MSB will determine the data inputs.
    3. Construct the implementation table:
    • Column 00 (y=0, z=0): minterms (x=0) and (x=1). Both are in the function list (1 and 1). Rule: (1, 1) Input = 1.
    • Column 01 (y=0, z=1): minterms (x=0) and (x=1). Both are in the list (1 and 1). Rule: (1, 1) Input = 1.
    • Column 10 (y=1, z=0): minterms (x=0) and (x=1). is absent (0), is present (1). Rule: (0, 1) Input = MSB = .
    • Column 11 (y=1, z=1): minterms (x=0) and (x=1). is present (1), is absent (0). Rule: (1, 0) Input = .
    1. The required data inputs are , , , .
    2. Matching with the options, the first circuit (Option A) shows exactly these inputs with and .
    Question 29 · Digital Logic · 2021_Set2 NAT

    If and are two decimal digits and , the decimal value of is __________.

    Correct Answer:

    3.00

    Step-by-Step Solution

    Insight: Convert the fully known binary fraction to Base 10, then expand the decimal fraction with unknowns and match coefficients.

    Exam route:

    1. .
    2. .
    3. Equate: .
    4. Multiply by 1000: . Since are single digits, .
    5. .

    Learning route:

    This is a mixed-base fractional equation. The most efficient strategy is to convert the fully known side to Base 10 first.

    Step 1: Convert to Base 10.

    The weights are , , , .

    .

    Step 2: Expand the right side using decimal positional weights.

    .

    Step 3: Equate the two Base 10 values.

    Multiply the entire equation by 1000 to clear decimals:

    Since and are single decimal digits (0-9), the only solution is and .

    Step 4: Calculate .

    Question 30 · Digital Logic · 2021_Set2 MCQ
    Suppose we want to design a synchronous circuit that processes a string of 0’s and 1’s. Given a string, it produces another string by replacing the first 1 in any subsequence of consecutive 1’s by a 0. Consider the following example.

    Input sequence:      00100011000011100
    Output sequence:   00000001000001100

    A Mealy Machine is a state machine where both the next state and the output are functions of the present state and the current input.
    The above mentioned circuit can be designed as a two-state Mealy machine. The states in the Mealy machine can be represented using Boolean values 0 and 1. We denote the current state, the next state, the next incoming bit, and the output bit of the Mealy machine by the variables , , and respectively.
    Assume the initial state of the Mealy machine is 0.

    What are the Boolean expressions corresponding to and in terms of and ?
    1. A.
    2. B.
    3. C.
    4. D.
    Correct Answer:

    B

    Step-by-Step Solution

    Insight: The problem describes a sequence processor that replaces the first '1' in a block of consecutive '1's with '0', while leaving subsequent '1's unchanged. This requires tracking whether we are currently inside a block of '1's.

    Exam route: Define state s=0 as "not in a block of 1s" and s=1 as "inside a block of 1s". Trace transitions: from s=0, input b=1 gives output y=0 (replaced) and next state t=1. From s=1, input b=1 gives output y=1 (unchanged) and next state t=1. This matches t=b and y=s AND b.

    Learning route:

    Step 1: Understand the Mealy machine requirement. Output y depends on current state s and input b.

    Step 2: Analyze state s=0. If b=0, we stay in s=0, output y=0. If b=1, this is the first '1', so output y=0, and we move to s=1. Thus, when s=0, t=b and y=0.

    Step 3: Analyze state s=1. If b=0, the block of '1's ends, so we move to s=0, output y=0. If b=1, it's a subsequent '1', so output y=1, and we stay in s=1. Thus, when s=1, t=b and y=b.

    Step 4: Combine the conditions. For t, in both s=0 and s=1, t=b. For y, y is 1 only when s=1 and b=1, which is the logical AND: y = s AND b.

    Step 5: Verify with the example. Input 0010001100... -> Output 0000000100... matches perfectly.

    Verification: Plugging s=0, b=1 into t=b, y=sb gives t=1, y=0. Plugging s=1, b=1 gives t=1, y=1. This perfectly matches the required behavior.

    Question 31 · Computer Networks · 2021_Set2 MCQ

    Consider the three-way handshake mechanism followed during TCP connection establishment between hosts P and Q. Let X and Y be two random 32-bit starting sequence numbers chosen by P and Q respectively. Suppose P sends a TCP connection request message to Q with a TCP segment having SYN bit = 1, SEQ number = X, and ACK bit = 0. Suppose Q accepts the connection request. Which one of the following choices represents the information present in the TCP segment header that is sent by Q to P?

    1. A.

      SYN bit = 1, SEQ number = X+1, ACK bit = 0, ACK number = Y, FIN bit = 0

    2. B.

      SYN bit = 0, SEQ number = X+1, ACK bit = 0, ACK number = Y, FIN bit = 1

    3. C.

      SYN bit = 1, SEQ number = Y, ACK bit = 1, ACK number = X+1, FIN bit = 0

    4. D.

      SYN bit = 1, SEQ number = Y, ACK bit = 1, ACK number = X, FIN bit = 0

    Question 32 · Computer Networks · 2021_Set2 MCQ

    Consider the cyclic redundancy check (CRC) based error detecting scheme having the generator polynomial . Suppose the message is to be transmitted. Check bits are appended at the end of the message by the transmitter using the above CRC scheme. The transmitted bit string is denoted by . The value of the checkbit sequence is

    1. A.

      101

    2. B.

      110

    3. C.

      100

    4. D.

      111

    Question 33 · Computer Networks · 2021_Set2 MSQ
    Consider a computer network using the distance vector routing algorithm in its network layer. The partial topology of the network is as shown below.

    R X Y Z Q P ... ... ...
    The objective is to find the shortest-cost path from the router to routers and . Assume that does not initially know the shortest routes to and . Assume that has three neighbouring routers denoted as , , and . During one iteration, measures its distance to its neighbours , , and as 3, 2, and 5, respectively. Router gets routing vectors from its neighbours that indicate that the distance to router from routers , , and are 7, 6, and 5, respectively. The routing vector also indicates that the distance to router from routers , , and are 4, 6, and 8, respectively. Which of the following statement(s) is/are correct with respect to the new routing table of , after updation during this iteration?
    1. A.

      The distance from to will be stored as 10.

    2. B.

      The distance from to will be stored as 7.

    3. C.

      The next hop router for a packet from to is .

    4. D.

      The next hop router for a packet from to is .

    Question 34 · Verbal Aptitude · 2021_Set2 MCQ

    Gauri said that she can play the keyboard __________ her sister.

    1. A.

      as well as

    2. B.

      as better as

    3. C.

      as nicest as

    4. D.

      as worse as

    Correct Answer:

    A

    Step-by-Step Solution

    Insight: The correlative conjunction "as ... as" strictly requires the positive degree of an adjective or adverb.

    Exam route: The sentence compares Gauri's ability to her sister's. The structure "as [adverb] as" demands the base (positive) form. "Well" is the positive adverb. "Better" and "worse" are comparative, and "nicest" is superlative. Thus, "as well as" is the only grammatically valid choice.

    Learning route:

    Step 1: Identify the comparison structure. The sentence uses "as ... as", which is the standard marker for the positive degree of comparison.

    Step 2: Evaluate the options based on degrees.

    • "well" is the positive degree of the adverb (good better best; well better best).
    • "better" is comparative and must be followed by "than", not "as".
    • "nicest" is superlative and requires "the" and a group context.
    • "worse" is comparative and requires "than".

    Step 3: Conclude that only "well" fits the "as ... as" sandwich.

    Common trap: Students might think "better" sounds more natural in casual speech, but "as better as" is a severe grammatical error in formal English.

    Verification: "Gauri said that she can play the keyboard as well as her sister." This correctly compares their skills using the positive degree.

    Question 35 · Verbal Aptitude · 2021_Set2 MCQ
    Listening to music during exercise improves exercise performance and reduces discomfort. Scientists researched whether listening to music while studying can help students learn better and the results were inconclusive. Students who needed external stimulation for studying fared worse while students who did not need any external stimulation benefited from music.

    Which one of the following statements is the CORRECT inference of the above passage?
    1. A.

      Listening to music has no effect on learning and a positive effect on physical exercise.

    2. B.

      Listening to music has a clear positive effect both on physical exercise and on learning.

    3. C.

      Listening to music has a clear positive effect on physical exercise. Music has a positive effect on learning only in some students.

    4. D.

      Listening to music has a clear positive effect on learning in all students. Music has a positive effect only in some students who exercise.

    Correct Answer:

    C

    Step-by-Step Solution

    Insight: Inference must combine the explicit facts from the passage without generalizing partial effects ("some students") to universal effects ("all students").

    Exam route: Fact 1 states music improves exercise. Fact 2 states music helps learning only for students who do not need external stimulation (i.e., "some" students). Option C combines these accurately.

    Learning route:

    1. Analyze the first sentence: "Listening to music during exercise improves exercise performance and reduces discomfort." This establishes a clear positive effect on physical exercise.
    2. Analyze the second and third sentences: The results on learning were "inconclusive" overall. Why? Because "students who needed external stimulation... fared worse" while "students who did not need any external stimulation benefited".
    3. Synthesize the learning effect: Music does NOT help everyone learn. It helps a specific subset (those who don't need external stimulation). Therefore, it has a positive effect on learning "only in some students".
    4. Evaluate Option A: Claims music has "no effect on learning". False, it benefited some students.
    5. Evaluate Option B: Claims a "clear positive effect... on learning". False, the overall results were inconclusive because it made some students fare worse.
    6. Evaluate Option C: "Clear positive effect on physical exercise" (Matches sentence 1). "Positive effect on learning only in some students" (Matches sentences 2 & 3). Correct.
    7. Evaluate Option D: Claims positive effect on learning in "all students". False, contradicts the text.
    8. Conclusion: Option C is the correct inference.
    Question 36 · Spatial Aptitude · 2021_Set2 MCQ

    A transparent square sheet shown above is folded along the dotted line. The folded sheet will look like ________.
    1. A.
    2. B.
    3. C.
    4. D.
    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: Folding a transparent sheet reflects the drawn patterns across the fold line, and because it is transparent, both the original and mirrored patterns are visible simultaneously (superposition).

    Step 1: Identify the fold line and direction.

    The dotted line is vertical, passing through the center (). The options show the right half remaining, implying the left half is folded over onto the right half.

    Step 2: Reflect the left-side patterns onto the right side.

    Original patterns on the LEFT ():

    • A curve segment in the bottom-left quadrant.
    • Two vertical line segments.

    Original patterns on the RIGHT ():

    • A curve segment in the bottom-right quadrant.
    • Two slanted/horizontal line segments.

    Step 3: Analyze the superposition on the right half.

    • The left curve mirrors across to perfectly overlap with the existing right curve (they form a continuous symmetric wave).
    • The two vertical lines on the left will mirror to become two vertical lines on the right side.
    • The original right-side patterns (two slanted lines) remain unchanged and visible through the transparent sheet.

    Step 4: Evaluate the options.

    • Option A shows both the two vertical lines (mirrored from the left) and the two slanted lines (original on the right). This matches our superposition analysis.
    • Option B distorts the curves and misses the line reflections.
    • Option C only shows the slanted lines, ignoring the mirrored vertical lines from the left half.
    • Option D shows a connected loop, which does not result from reflecting disjoint vertical lines.

    Answer: A

    Question 37 · Spatial Aptitude · 2021_Set2 MCQ

    A jigsaw puzzle has 2 pieces. One of the pieces is shown above. Which one of the given options for the missing piece when assembled will form a rectangle? The piece can be moved, rotated or flipped to assemble with the above piece.
    1. A.
    2. B.
    3. C.
    4. D.
    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: This is a shape assembly problem requiring us to find the complementary piece that forms a rectangle when combined with the given jigsaw piece.

    Step 1: Analyze the given piece.

    The provided piece has a complex boundary with specific protrusions (outward bumps) and indentations (inward cuts).

    Step 2: Determine the required negative space.

    To form a rectangle, the missing piece must have the exact geometric inverse of this boundary. Every protrusion on the given piece must fit into an indentation on the missing piece, and vice versa.

    Step 3: Check the outer boundary requirements.

    The combined shape must be a rectangle. Therefore, the missing piece must supply the straight outer edges that the given piece lacks to complete the rectangular perimeter.

    Step 4: Evaluate the options.

    Option A, when appropriately rotated or flipped, provides the exact complementary boundary features and the necessary straight edges to form a perfect rectangle without gaps or overlaps. Options B, C, and D have mismatched sequences of bumps and cuts.

    Answer: A

    Question 38 · Analytical Aptitude · 2021_Set2 MCQ
    Pen : Write :: Knife : _________

    Which one of the following options maintains a similar logical relation in the above?
    1. A.

      Vegetables

    2. B.

      Sharp

    3. C.

      Cut

    4. D.

      Blunt

    Correct Answer:

    C

    Step-by-Step Solution

    Insight: This is a Tool-to-Function analogy. The relationship is "A [Tool] is primarily used to [Action]".

    Exam route: A Pen is used to Write. Applying the same bridge sentence, a Knife is used to Cut.

    Learning route:

    Step 1: Isolate the given pair: Pen : Write.

    Step 2: Formulate the Bridge Sentence: "A [Pen] is a tool used to [Write]."

    Step 3: Test this exact sentence structure on the target: "A [Knife] is a tool used to [?]."

    Step 4: Evaluate options. "Cut" fits perfectly. "Vegetables" is the object acted upon, not the action. "Sharp" is an attribute, not a function. "Blunt" is the opposite attribute.

    Step 5: Verify directionality. Tool Function. Pen Write. Knife Cut. The logical relation is perfectly maintained.

    Question 39 · Analytical Aptitude · 2021_Set2 MCQ
    Six students P, Q, R, S, T and U, with distinct heights, compare their heights and make the following observations.

    Observation I: S is taller than R.

    Observation II: Q is the shortest of all.

    Observation III: U is taller than only one student.

    Observation IV: T is taller than S but is not the tallest.

    The number of students that are taller than R is the same as the number of students shorter than ______.
    1. A.

      T

    2. B.

      R

    3. C.

      S

    4. D.

      P

    Correct Answer:

    C

    Step-by-Step Solution

    Insight: Anchor the extremes (shortest, tallest) first, then chain the relative inequalities to build the complete order.

    Exam route: Q is shortest (Rank 1). U is taller than only one (Rank 2). Remaining: P, R, S, T for Ranks 3, 4, 5, 6. We know T > S > R. Since T is not the tallest, P must be Rank 6 (tallest). This forces T = 5, S = 4, R = 3. Students taller than R (Ranks 4, 5, 6) = 3. Students shorter than S (Ranks 1, 2, 3) = 3. Match is S.

    Learning route:

    Step 1: Assign absolute ranks to extremes. Q = 1 (shortest). U = 2 (taller than only Q).

    Step 2: Identify the remaining pool: {P, R, S, T} for ranks {3, 4, 5, 6}.

    Step 3: Chain the relative clues: T > S and S > R T > S > R.

    Step 4: Apply the negative constraint: "T is not the tallest". Since T > S > R, T must be at least Rank 4. If T were Rank 6, it would be the tallest. Thus, P must be Rank 6.

    Step 5: Fill the remaining slots: T = 5, S = 4, R = 3.

    Step 6: Answer the specific query. Taller than R (Ranks 4, 5, 6 S, T, P) is 3 students. We need someone with exactly 3 students shorter than them. S (Rank 4) has Ranks 1, 2, 3 (Q, U, R) shorter than them. Count = 3. Match confirmed.

    Other GATE CS papers