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.
Which sequences can be the preorder traversal of a binary search tree?
Show answer and explanation
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.
Which are valid topological orders of this DAG?
Show answer and explanation
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.
Which statements are true?
Show answer and explanation
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.