LearnFrenzy
Sign in Take a free test

DSA & Algorithms · Topic 13 of 13

GATE-Style DSA & Algorithms Questions (MSQ & NAT): questions with answers

Multiple-select and numerical-answer questions in the GATE CSE pattern: valid traversal orders, heaps, stack permutations, shortest paths, MSTs, dynamic programming, Huffman coding and recurrences.

Questions
45
Timed sets
3
Answers run or computed
39
Your accuracy
–

What this topic covers

12 subtopics
  • Graphs9
  • Dynamic programming7
  • Trees7
  • Complexity5
  • Sorting4
  • Heaps3
  • Greedy2
  • Hashing2
  • Recursion2
  • Stacks2
  • Data structures1
  • Searching1
  • Beginner 15
  • Intermediate 15
  • Advanced 15

About this topic

GATE's data-structures and algorithms questions are about precision: is this sequence a possible BFS order, which arrays are heaps, what is the exact MST weight or LCS length. Every multiple-select question here was checked by running the algorithm on each option, and every number was computed. These are pattern questions written for practice, not previous-year questions.

Free preview

Sample questions

Try each one first, then open the answer for the explanation and why the other options are wrong.

Question 1 Trees Beginner Practice Answer computed One or more answers

Which sequences can be the preorder traversal of a binary search tree?

8 5 9 7 10
10 5 1 7 40 50
50 30 20 40 70 60 80
40 30 35 20 50
Show answer and explanation
Correct answer BC

Explanation

In a BST preorder, once you move to a right subtree (a value larger than an ancestor), no later value may be smaller than that ancestor. In 8 5 9 7 10, 7 comes after 9 although 9 is in 8's right subtree; in 40 30 35 20, 20 follows 35 inside 30's right subtree.

Question 2 Graphs Intermediate Practice Answer computed One or more answers

Which are valid topological orders of this DAG?

Directed acyclic graph
ABCDEF
A D B E C F
B A C D E F
A B C D E F
A B D C E F
A B E D C F
Show answer and explanation
Correct answer ACD

Explanation

Every edge must point forwards in the order. A B E D … puts E before D although D → E; B A … puts B before A although A → B.

Question 3 Graphs Advanced Practice One or more answers

Which statements are true?

Dijkstra's algorithm can give wrong distances when some edge weights are negative
Bellman–Ford detects a negative cycle reachable from the source
Floyd–Warshall runs in O(V²) time
Adding the same constant to every edge weight keeps all shortest paths unchanged
BFS finds shortest paths in an unweighted graph
Show answer and explanation
Correct answer ABE

Explanation

Adding a constant penalises paths with more edges, so shortest paths can change. Floyd–Warshall is O(V³).

Why the other options are wrong

  • CO(V³).
  • DPaths with more edges get more expensive.
42 more questions in the timed setsSame format as the samples, with a timer, a question palette and a full review at the end.
Start practising

DSA & Algorithms

All 13 topics

Topics, levels and full mocks
  1. 01 Time and Space Complexity45 questions · 3 levels
  2. 02 Arrays and Strings45 questions · 3 levels
  3. 03 Linked Lists45 questions · 3 levels
  4. 04 Stacks and Queues45 questions · 3 levels
  5. 05 Hashing45 questions · 3 levels
  6. 06 Recursion and Backtracking45 questions · 3 levels
  7. 07 Sorting and Searching45 questions · 3 levels
  8. 08 Trees and BST45 questions · 3 levels
  9. 09 Heaps and Priority Queues45 questions · 3 levels
  10. 10 Graphs45 questions · 3 levels
  11. 11 Dynamic Programming45 questions · 3 levels
  12. 12 Greedy and Bit Manipulation45 questions · 3 levels
  13. 13 GATE-Style DSA & Algorithms Questions (MSQ & NAT)45 questions · 3 levels

Search LearnFrenzy

Esc

Quick links