Data Structures rounds out the “Basics of Mechatronics” section (A.2) of the GATE Robotics and Automation (RA) 2027 syllabus and connects directly to the programming and automation software that robotics runs on. The examined structures are the stack, queue, linked list, binary search tree, binary heap and graph, and the questions test their operations, ordering and complexity. This guide reviews each and works through six GATE-style problems in full.
TABLE OF CONTENTS
Stacks & queues
A stack is a last-in-first-out (LIFO) structure with push and pop at one end — used for function calls, undo, and postfix expression evaluation. A queue is first-in-first-out (FIFO), with enqueue at the rear and dequeue at the front — used for scheduling and breadth-first search. Both offer O(1) insertion and removal.
Linked lists
A linked list stores elements in nodes, each holding data and a pointer to the next node. Unlike arrays, insertion and deletion are O(1) once the position is known, but random access is O(n) because you must walk the chain. Doubly and circular linked lists add backward and wrap-around links.
Binary search trees
A binary search tree (BST) keeps every left child less than its parent and every right child greater, so an in-order traversal visits the keys in sorted order. Search, insert and delete run in O(h) time, where h is the height — O(log n) if balanced, O(n) in the worst (skewed) case. A binary tree of height h holds at most 2h+1 − 1 nodes.
Serious about GATE RA 2027? Get structured video lectures, PYQs, notes and a full test series — taught by Piyush Wairale (IIT Madras).
Binary heaps
A binary heap is a complete binary tree stored in an array, satisfying the heap property (in a max-heap every parent ≥ its children). Using 1-based indexing, the node at index i has children at 2i and 2i+1 and parent at ⌊i/2⌋. Insertion and extraction are O(log n), which makes heaps the basis of priority queues and heap-sort.
Graphs
A graph is a set of vertices connected by edges, stored as an adjacency matrix or adjacency list. A complete graph on n vertices has n(n−1)/2 edges (undirected). Traversals use breadth-first search (a queue) and depth-first search (a stack or recursion), the backbone of path-planning in robotics.
Worked examples (GATE-style)
Example 1 — postfix evaluation (stack)
Evaluate the postfix expression 2 3 4 * + using a stack.
Solution. Push 2, 3, 4. On *: pop 4 and 3 → 12, push it. On +: pop 12 and 2 → 14.
Result = 14 (i.e. 2 + 3×4).
Example 2 — edges in a complete graph
How many edges does a complete undirected graph on 6 vertices have?
Solution. Edges = n(n−1)/2 = 6×5/2 = 30/2.
= 15 edges.
Example 3 — maximum nodes in a binary tree
What is the maximum number of nodes in a binary tree of height 3 (root at height 0)?
Solution. Maximum nodes = 2h+1 − 1 = 24 − 1 = 16 − 1.
= 15 nodes.
Example 4 — heap array indices
In a binary heap stored with 1-based indexing, what are the array indices of the children of the node at index 3?
Solution. Children of index i are at 2i and 2i+1, so for i = 3 they are 6 and 7.
Children at indices 6 and 7.
Example 5 — BST in-order traversal
Keys 5, 3, 8, 1, 4 are inserted into a binary search tree. What does an in-order traversal output?
Solution. An in-order traversal of a BST always yields the keys in ascending sorted order.
Output = 1, 3, 4, 5, 8.
Example 6 — queue order
Items A, B, C are enqueued in that order, then one item is dequeued. Which item is removed, and what remains at the front?
Solution. A queue is FIFO, so the first item enqueued (A) is dequeued first.
Removed = A; new front = B.
Quick reference
QUICK REFERENCE
Stack / Queue: LIFO / FIFO, O(1) ops
Linked list: O(1) insert, O(n) access
BST: in-order = sorted, search O(h)
Binary tree: max nodes = 2h+1 − 1
Heap (1-based): children 2i, 2i+1; parent ⌊i/2⌋
Complete graph: edges = n(n−1)/2
Common mistakes to avoid
- Swapping LIFO and FIFO — a stack reverses order, a queue preserves it.
- Using 0-based heap formulas with a 1-based array (or vice versa) — children are 2i, 2i+1 for 1-based, 2i+1, 2i+2 for 0-based.
- Confusing height and depth conventions when counting maximum nodes.
- Forgetting a BST’s worst case — a skewed tree degrades search to O(n).
- Counting directed and undirected edges the same — a complete directed graph has n(n−1) edges.
GATE ROBOTICS & AUTOMATION 2027
Master Data Structures for GATE RA
Join the complete GATE RA course by Piyush Wairale (IIT Madras) — full syllabus coverage, PYQs, live doubt-clearing and an exam-focused test series that turns tough topics into guaranteed marks.
Basics of Mechatronics — full solved-problem series
This guide is one part of the Section A.2 (Basics of Mechatronics) solved-problem series. Work through every sub-topic:
See also the umbrella guide, Basics of Mechatronics — Important Questions, and the complete GATE RA 2027 Syllabus.
Frequently asked questions
What is the difference between a stack and a queue?
A stack is last-in-first-out (LIFO): the most recently pushed item is popped first. A queue is first-in-first-out (FIFO): the earliest enqueued item is dequeued first. Stacks suit recursion and backtracking; queues suit scheduling and breadth-first search.
Why does an in-order traversal of a BST give sorted output?
Because a binary search tree keeps every left subtree smaller and every right subtree larger than the node, visiting left–root–right (in-order) naturally produces the keys in ascending order.
How many edges does a complete graph have?
A complete undirected graph on n vertices has n(n−1)/2 edges, since every pair of vertices is joined exactly once. For n = 6 that is 15 edges. A complete directed graph has twice as many, n(n−1).
This solved-problems guide is part of the complete GATE RA 2027 Syllabus overview and the Basics of Mechatronics syllabus guide.
Recent Post

The complete GATE General Aptitude 2027 guide: official GA syllabus, exam pattern, section-wise weightage, a 4-week preparation plan and links to all 16 free topic-wise guides for Verbal, Quantitative, Analytical and Spatial Aptitude, by Piyush Wairale (IIT Madras).

Paper folding, cutting, pattern completion, figure series and embedded figures for GATE Spatial Aptitude 2027: the unfold-in-reverse method with the 2^n hole rule, sketch-and-mirror for cuts, rotation and count tracking for series, 8 solved PYQs, three diagrams, practice set and rule sheet by Piyush Wairale (IIT Madras).

Dice, cube nets, painted cubes, cube counting, assembling and grouping for GATE Spatial Aptitude 2027: the two-views rule, the 11 nets of a cube, the 8 / 12(n-2) / 6(n-2)^2 / (n-2)^3 formulas, Euler's formula, four diagrams, 8 solved PYQs and GATE-style questions, a practice set and a rule sheet by Piyush Wairale (IIT Madras).

Master 2D transformations for GATE Spatial Aptitude 2027: rotation by 90, 180 and 270 degrees, mirror and water images, symmetric letters and digits, the clock mirror rule, combined transformations and shape-matching MCQs, with 8 solved questions, four diagrams, a practice set and a one-page rule sheet by Piyush Wairale (IIT Madras).

Solve Puzzles, Seating Arrangement, Blood Relations and Direction Sense for GATE General Aptitude 2027: circular and linear arrangement method, family-tree decoding, coordinate method for directions, diagrams, 8 solved PYQs, practice set and rule sheet by Piyush Wairale (IIT Madras).

Crack Analogy, Series and Numerical Relations for GATE General Aptitude 2027: number and letter series methods, word and number analogies, coding-decoding, grid and operator puzzles, 8 solved PYQs, practice set and rule sheet by Piyush Wairale (IIT Madras).
Learn Daily, Wherever You Are
Free lectures, exam updates, PYQ discussions, and job alerts — delivered through our YouTube channel and Telegram communities.


