chapter

    Algorithms Notes for Gate Cs

    GATE CS Algorithms: 1 units and 5 chapters, weightage from 47 previous year questions across 10 papers, a study order by exam weight and 1355 practice questio

    A question from this chapter

    Question 1
    Level 1: Warm-up

    Consider the following recurrence relations:

    How many of these recurrences can be directly solved using the standard Master Theorem without falling into its failure cases or requiring a change of variables?

    Question 2
    Level 1: Warm-up

    In the randomized hashing strategy to defend against an adversary, the security guarantee relies on the chronological order of events. Let:

    E1: The adversary commits to a specific set of keys to insert.

    E2: The system randomly selects a hash function from a universal family .

    E3: The system inserts the keys using the selected .

    Which ordering of these events ensures that the adversary cannot force all keys into a single slot?

    Question 3
    Level 1: Warm-up

    Consider the following statements about Depth-First Search on an undirected graph :

    (I) Every non-tree edge is a back edge.

    (II) The DFS forest can contain forward edges.

    (III) If an edge connects to an already visited vertex, it must be a back edge.

    Which of the above statements is/are TRUE?

    Question 4
    Level 1: Warm-up

    Let be a connected undirected weighted graph with distinct edge weights. Which of the following scenarios is IMPOSSIBLE?

    Question 5
    Level 1: Warm-up

    In the rod cutting problem with rod length and price array , the correct recurrence for maximum revenue is

    Free preview ends here

    Login to view the complete notes

    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.

    Explore complete test series, official past papers, and chapter-wise study tools.

    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.

    Algorithms Notes for GATE CS

    GATE CS Algorithms: 1 units and 5 chapters, weightage from 47 previous year questions across 10 papers, a study order by exam weight and 1355 practice questions.

    About Algorithms Notes

    Full study notes for Algorithms in GATE CS, organised across 5 chapters. Each chapter page explains concepts from the basics with worked examples and the formulas you need.

    GATE CS Algorithms Unit-wise Weightage from Past Papers

    We counted every GATE CS Algorithms previous year question in our bank (47 questions from 10 papers) and grouped them by unit.

    UnitChaptersPYQsShare of sectionAvg per paper
    Algorithms547100%4.7

    Suggested Algorithms Study Order for GATE CS

    1. Algorithms: 100% of past Algorithms questions, about 4.7 per paper.

    Start where the marks are. Units at the top of this list have appeared most often in past GATE CS papers.

    Units in GATE CS Algorithms

    All Algorithms chapters

    One Solved Question from Each Algorithms Chapter

    Question 1 · Asymptotic Analysis and Recurrence Relations MCQ

    Consider the following recurrence relations:

    How many of these recurrences can be directly solved using the standard Master Theorem without falling into its failure cases or requiring a change of variables?

    1. A.

      1

    2. B.

      2

    3. C.

      3

    4. D.

      4

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: The Master Theorem applies when and the critical function have a polynomial gap, or match exactly with a log factor.

    Step 1: For , critical is . matches exactly. Case 2 applies. (Works)

    Step 2: For , critical is . matches with . Case 2 applies. (Works)

    Step 3: For , critical is . is smaller, but only by a logarithmic factor, not a polynomial one. Master Theorem fails. (Fails)

    Step 4: For , critical is . is polynomially larger. Case 3 applies. (Works)

    Step 5: Recurrences 1, 2, and 4 work. Total count is 3.

    Answer: C

    Question 2 · Searching, Sorting, Selection and Hashing MCQ

    In the randomized hashing strategy to defend against an adversary, the security guarantee relies on the chronological order of events. Let:

    E1: The adversary commits to a specific set of keys to insert.

    E2: The system randomly selects a hash function from a universal family .

    E3: The system inserts the keys using the selected .

    Which ordering of these events ensures that the adversary cannot force all keys into a single slot?

    1. A.

      E2 E1 E3

    2. B.

      E2 E3 E1

    3. C.

      E1 E2 E3

    4. D.

      E1 E3 E2

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: The core defense of universal hashing is that the adversary must commit to their keys <b>before</b> knowing which hash function is selected.

    Step 1: Analyze the requirement. For randomization to work, must be unknown to the adversary when they choose their keys.

    Step 2: Evaluate the order. The adversary must choose keys (E1) first. Then the system picks (E2). Finally, the system inserts (E3).

    Step 3: This corresponds to the sequence E1 E2 E3.

    Answer: The correct ordering is E1 E2 E3.

    Question 3 · Graph Traversal, Connectivity and Directed Graphs MCQ

    Consider the following statements about Depth-First Search on an undirected graph :

    (I) Every non-tree edge is a back edge.

    (II) The DFS forest can contain forward edges.

    (III) If an edge connects to an already visited vertex, it must be a back edge.

    Which of the above statements is/are TRUE?

    1. A.

      I only

    2. B.

      I and III only

    3. C.

      II and III only

    4. D.

      I, II, and III

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: This is a bounding question testing the edge classification theorem for undirected DFS. Evaluate each statement against the theorem that undirected DFS produces only tree and back edges.

    Evaluating each statement:

    Statement I: "Every non-tree edge is a back edge." TRUE. Since undirected DFS produces only tree and back edges, every non-tree edge must be a back edge.

    Statement II: "The DFS forest can contain forward edges." FALSE. This is the ignoring_constraint trap. The theorem explicitly states that forward edges cannot exist in undirected DFS.

    Statement III: "If an edge connects to an already visited vertex, it must be a back edge." TRUE. In undirected DFS, if an edge is explored and is already visited (gray or black), then must be an ancestor of , making a back edge.

    Therefore, statements I and III are true, and II is false.

    Why option D is the trap: A student might think all three are true, forgetting that forward edges cannot exist in undirected DFS.

    Verification: The theorem guarantees that undirected DFS produces only tree and back edges. This makes I and III true, and II false.

    Answer: B

    Question 4 · Minimum Spanning Trees and Shortest Paths MCQ

    Let be a connected undirected weighted graph with distinct edge weights. Which of the following scenarios is IMPOSSIBLE?

    1. A.

      The edge with the maximum weight in is part of the MST.

    2. B.

      The edge with the minimum weight in is not part of the MST.

    3. C.

      The MST contains exactly edges, where is the number of vertices in .

    4. D.

      All edges in the MST have weights strictly less than the maximum edge weight in .

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: This is a summary properties question. We check each scenario against MST properties.

    Step 1: Check option A. The maximum weight edge can be in the MST if it is a bridge (an edge whose removal disconnects the graph). For example, in a tree, all edges are in the MST, including the maximum weight edge. So A is possible.

    Step 2: Check option B. By the Cut Property (and card c007), the global minimum edge is always in every MST. So it is impossible for the minimum weight edge to not be in the MST. B is impossible.

    Step 3: Check option C. By definition, any spanning tree of a graph with vertices has exactly edges. So C is always true, hence possible.

    Step 4: Check option D. If the maximum weight edge is not a bridge, it will not be in the MST (by the Cycle Property). In this case, all edges in the MST have weights less than the maximum edge weight in . So D is possible.

    Answer: B

    Question 5 · Dynamic Programming, Greedy Algorithms and Optimization MCQ

    In the rod cutting problem with rod length and price array , the correct recurrence for maximum revenue is

    1. A.

    2. B.

    3. C.

    4. D.

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: The recurrence must include the option of not cutting the rod at all (selling it whole), which corresponds to .

    Step 1: For a rod of length , we try every possible first cut of length where .

    Step 2: If we cut a piece of length , we earn (price of piece ) plus (optimal revenue for remaining length ).

    Step 3: When , the remaining length is , and . So the term becomes , which represents selling the rod uncut.

    Step 4: The recurrence is:

    with base case .

    Answer: B