CS-303 AD-303 IS-303 Data Structures

Data Structures Important Questions

RGPV · B.Tech · CSE · Semester 3 · Current scheme · 13 papers (2020 to 2025)

  1. Read the answers

    Start with the topics that come every year.

  2. Revise unit notes

    Go through each unit once to score more.

Paperwala Imp Topics - Data Structures important questions

Download Paperwala Imp Question & Answer (PDF)

Counted from the questions in the past papers listed on this site. Repeated = how many times the topic came in those papers.

Data Structures important questions with answers

Each answer starts with the short answer. Then come the points to write, a diagram and an exam tip. The questions under each topic are copied from the RGPV papers.

Q1. Infix to postfix conversion and postfix evaluation

Asked 11 times in 2020, 2022, 2023, 2024, 2025 · Unit 2

From the papers

  • “Write a 'C' program to convert the infix expression to postfix expression.” (2020, 2023, 2024)
  • “How can you convert an infix expression to postfix expression using stack? Give one example.” (2020, 2024)
  • “Post fix expression evaluation” (2022, 2024)

The short answer

In infix form the operator sits between its operands (A + B), while in postfix form it comes after them (A B +). Postfix needs no brackets, so one stack can evaluate it.

Write these points

  1. Precedence from high to low: ^ (right to left), then * and /, then + and -. Equal operators go left to right.
  2. Conversion uses an operator stack. Operands go straight to the output.
  3. For an operator, pop every stack operator of equal or higher precedence to the output, then push the new one.
  4. A left bracket is pushed. A right bracket pops to the output until the left bracket. At the end pop the whole stack.
  5. Evaluation uses an operand stack. Push operands. For an operator pop b, pop a, then push a op b.

Steps

  1. Evaluate 5 3 2 * + 4 -: push 5, 3, 2. The * gives 3 * 2 = 6. The + gives 5 + 6 = 11. Push 4. The - gives 11 - 4 = 7.

Convert, then evaluate.

Convert A + B * C: A goes out. Push +. B goes out. * is higher than +, so push it. C goes out.

At the end pop * then +. Postfix = A B C * +.

Evaluate 6 2 3 + − 3 8 2 / + *: push 6, 2, 3. + pops 3 and 2, pushes 5. − pops 5 and 6, pushes 1.

Push 3, 8, 2. / gives 8 / 2 = 4. + gives 3 + 4 = 7. * gives 1 × 7 = 7.

Real-life example

A shop calculator that shows 2 + 3 × 4 = 14 does not work left to right. Inside, it turns your input into postfix (2 3 4 × +) with a stack and then works it out with another stack. That is why it follows precedence.

Figure: Infix to postfix conversion and postfix evaluation
Figure: Infix to postfix conversion and postfix evaluation

Same or opposite: infix and postfix notation

PointInfixPostfixSame or opposite
Operator positionBetween operandsAfter operandsOpposite
Brackets neededYesNoOpposite
Evaluated withPrecedence rulesOne operand stackOpposite
Same valueYesYesSame

Exam tip. Draw the stack and output after every symbol. The first value popped is the right operand b. Check by writing the postfix back as infix.

Back to the topic list

Q2. Singly and circular linked list: representation and operations

Asked 11 times in 2020, 2022, 2023, 2024, 2025 · Unit 1

From the papers

  • “Write an algorithm for traversing nodes in a single linked list? Explain with an example.” (2020, 2024)
  • “Write an algorithm for insert and delete operations in circular linked list.” (2023, 2024)
  • “Describe the memory representation of a Singly Linked List. Write an algorithm to insert a node at a specific position in a linked list.” (2025)

The short answer

A linked list is a chain of nodes where each node holds data with a pointer to the next node. Nodes can sit anywhere in memory, so the list grows at run time.

Write these points

  1. Node in C: struct node { int data; struct node *next; }. The pointer head holds the first node and the last node points to NULL.
  2. In a circular list the last node points back to the first, so no node holds NULL. A doubly list has prev and next pointers.
  3. Insert and delete need no shifting, unlike an array. The cost is extra memory for pointers and no access by index.

Steps

  1. Traverse: ptr = head. While ptr != NULL: print ptr->data, ptr = ptr->next.
  2. Insert after node ptr: new->next = ptr->next, then ptr->next = new. Set new->next first.
  3. Delete after node ptr: temp = ptr->next, ptr->next = temp->next, free(temp).
  4. Circular insert at end: new->next = head, last->next = new. Traversal stops when ptr->next == head.

Insert, delete and walk a circular list.

List 10 → 20 → 30. Insert 25 after node p = 20: new.next = p.next (30), then p.next = new.

The list is now 10 → 20 → 25 → 30. The order of the two steps matters, or 30 is lost.

Delete the first node: head = head.next. The list is 20 → 25 → 30.

Make it circular: last.next = head. Counting nodes stops when the pointer comes back to head, giving 3.

Real-life example

A music app playlist is a linked list. Each song knows the next one. Turn on 'repeat all' and the last song points back to the first, which makes it a circular list.

Figure: Singly and circular linked list: representation and operations
Figure: Singly and circular linked list: representation and operations

Same or opposite: singly and circular linked list

PointSinglyCircularSame or opposite
Last node points toNULLThe first nodeOpposite
End of traversal testptr == NULLptr->next == headOpposite
Insert needs no shiftingYesYesSame
Good forSimple listsRound robin turnsOpposite

Exam tip. Draw the list before and after each change. Set the new pointer before you break the old link. Circular end test is ptr->next == head.

Back to the topic list

Q3. Queue: simple, circular, priority and double ended queue

Asked 9 times in 2020, 2022, 2023, 2024, 2025 · Unit 2

From the papers

  • “Queue using linked list” (2022, 2024)
  • “Explain the concept of Queue simulation with a real-world example.” (2025)
  • “Explain the addition and deletion operations performed on a circular queue with necessary algorithms.” (2024)

The short answer

A queue is a linear structure. Items are added at the rear and removed from the front, so the first item in is the first item out (FIFO).

Write these points

  1. Array queue: enqueue puts the item at Q[++rear]. Dequeue takes Q[front++]. Overflow is rear == MAX-1.
  2. A simple queue wastes freed space. A circular queue wraps with mod n: rear = (rear+1) % n. It is full when (rear+1) % n == front.
  3. Linked queue keeps front and rear pointers. Insert at the rear node and delete at the front node.
  4. A priority queue removes the highest priority item first (a heap implements it). A deque works at both ends.
  5. Uses: CPU scheduling, printer jobs, buffers and BFS.
TypeInsert atDelete from
SimpleRearFront
CircularRear (wraps)Front (wraps)
PriorityBy priorityHighest priority
DequeEither endEither end

Circular queue of size 5.

Enqueue 10, 20, 30, 40, 50: rear = 4 and the queue is full.

Dequeue twice: 10 and 20 leave, front = 2.

Enqueue 60: rear = (4 + 1) mod 5 = 0. Enqueue 70: rear = 1.

Full test: (rear + 1) mod 5 = 2 = front, so it is full again with 30, 40, 50, 60, 70.

A simple linear queue would report full at rear = 4 although slots 0 and 1 were empty.

Real-life example

A ticket counter line is a queue: first come, first served. A hospital emergency room is a priority queue: the most serious patient goes first, whoever came earlier.

Figure: Queue: simple, circular, priority and double ended queue
Figure: Queue: simple, circular, priority and double ended queue

Same or opposite: simple queue and circular queue

PointSimple queueCircular queueSame or opposite
Space after deletionsWasted at the frontReused by wrapping roundOpposite
Rear moves asrear + 1(rear + 1) mod nOpposite
Full testrear == n − 1(rear + 1) mod n == frontOpposite
FIFO orderYesYesSame

Exam tip. Show front and rear for every step. Write the full test (rear+1) % n == front.

Back to the topic list

Q4. Data structures: classification, ADT, operations and cost

Asked 8 times in 2020, 2022, 2023, 2024, 2025 · Unit 1

From the papers

  • “Explain the classification of data structures in detail.” (2025)
  • “Define Abstract Data Types (ADT). Explain the different operations performed on data structures and describe the criteria for cost estimation.” (2025)
  • “Define data structures. Classify different types of data structures.” (2024)

The short answer

A data structure is a way of storing data so that search, insert and delete are done efficiently. An abstract data type (ADT) lists the values and operations without saying how they are coded.

Write these points

  1. Primitive: int, float, char, pointer. Non-primitive: linear (array, list, stack, queue) and non-linear (tree, graph).
  2. Static structures have fixed size (array). Dynamic structures grow at run time (linked list, dynamic array that doubles when full).
  3. ADT example: stack has push, pop, peek and isEmpty. The user does not see the array or list inside.
  4. Operations: traversal, insertion, deletion, searching, sorting and merging.
  5. Cost is time and space in Big O, for best, average and worst case.
StructureSearchInsertDelete
ArrayO(n)O(1) at endO(n)
Linked listO(n)O(1) at headO(n)
Stack or queueO(n)O(1)O(1)
Balanced BSTO(log n)O(log n)O(log n)

Why the choice of structure matters.

Search for a roll number among 1,000,000 records.

Unsorted array, linear search: up to 1,000,000 comparisons, O(n).

Sorted array, binary search: at most ⌈log₂ 1,000,000⌉ = 20 comparisons, O(log n).

The Stack ADT (push, pop, peek, isEmpty) is the same whether it is coded with an array or a linked list.

Real-life example

A library keeps books on shelves by number (array), a waiting list for new books (queue) and a catalogue tree by subject. Each one is a different data structure picked for the job it must do fast.

Figure: Data structures: classification, ADT, operations and cost
Figure: Data structures: classification, ADT, operations and cost

Same or opposite: linear and non-linear data structure

PointLinearNon-linearSame or opposite
ArrangementOne after anotherLevels or a networkOpposite
ExamplesArray, stack, queue, listTree, graphOpposite
TraversalOne passMany pathsOpposite
Stores data with operationsYesYesSame

Exam tip. Draw the classification chart first. Define ADT in one line with an example.

Back to the topic list

Q5. Minimum spanning tree: Kruskal and Prim algorithms

Asked 8 times in 2020, 2022, 2023, 2024, 2025 · Unit 4

From the papers

  • “Discuss Kruskal's algorithm with an following graph.” (2022, 2023, 2024)
  • “What is a Minimum Spanning Tree (MST)? Explain Kruskal's or Prim's algorithm to find the MST of a weighted graph.” (2025)
  • “Define minimum spanning tree. Write down Prim's algorithm to find minimum spanning tree.” (2024)

The short answer

A spanning tree of a connected graph with n vertices has all n vertices and n-1 edges with no cycle. The minimum spanning tree (MST) has the smallest total weight.

Write these points

  1. Kruskal is edge based. Sort the edges. Add an edge if it makes no cycle. Stop at n-1 edges. Time O(E log E).
  2. Prim is vertex based. Grow one tree from any vertex. Each time add the cheapest edge to a new vertex. Time O(V^2), or O(E log V) with a heap.
KruskalPrim
Works onEdgesVertices
Cycle checkNeededNot needed
Best forSparse graphDense graph

Steps

  1. Kruskal on the picture: sorted edges 3, 4, 5, 6, 7, 8, 9. Take 3, 4 and 5. Skip 6 (cycle 1-2-3). Take 7. Four edges, cost 19.
  2. Prim from 0: pick 0-1 (4), then 1-2 (3), then 2-3 (5), then 3-4 (7). Cost 19. Both methods give the same cost.
  3. In the exam repeat these steps on the given graph and list the chosen edges.

Kruskal and Prim on one graph.

Edges: AB 1, CD 2, BC 3, AC 4, DE 5, BE 6, CE 7 on vertices A to E.

Kruskal takes them in order: AB 1, CD 2, BC 3. AC 4 would make the cycle A, B, C, so skip it. DE 5 completes the tree.

That is 4 edges = n − 1. Total weight = 1 + 2 + 3 + 5 = 11.

Prim from A adds AB 1, then BC 3, then CD 2, then DE 5. The total is again 11.

Real-life example

A cable TV company wants to connect every house in a colony with the least wire, with no loops. The cheapest such layout is a minimum spanning tree of the street map.

Figure: Minimum spanning tree: Kruskal and Prim algorithms
Figure: Minimum spanning tree: Kruskal and Prim algorithms

Same or opposite: Kruskal and Prim

PointKruskalPrimSame or opposite
Grows byCheapest edge anywhereCheapest edge from the treeOpposite
Cycle checkNeeded (union-find)Not neededOpposite
Best forSparse graphsDense graphsOpposite
Gives the same total costYesYesSame

Exam tip. An MST of n vertices has n-1 edges. Write the total cost at the end.

Back to the topic list

Q6. Binary tree traversals: inorder, preorder and postorder

Asked 8 times in 2020, 2023, 2024, 2025 · Unit 3

From the papers

  • “How a binary search tree is traversed? Explain with a suitable example.” (2023, 2024)
  • “Write functions to implement recursive versions of preorder, inorder and postorder traversals of a binary tree.” (2020, 2024)
  • “Define a Binary Search Tree (BST). Explain the algorithms for In-order, Pre-order, and Post-order traversal with an example.” (2025)

The short answer

A traversal visits every node of a binary tree once. The three depth first orders differ in when the node is visited.

Write these points

  1. Inorder: left, node, right. For a BST it gives sorted keys.
  2. Preorder: node, left, right. It gives the prefix form of an expression tree.
  3. Postorder: left, right, node. It gives the postfix form. Every traversal takes O(n) time.
  4. Pseudocode inorder(t): if t != NULL then inorder(t->left), visit t, inorder(t->right). The other two only move the visit line.

Example.

Tree from inorder D B E A C and postorder D E B C A: the last item of postorder, A, is the root. D B E is left of A and C is right. The postorder of the left part is D E B, so B is its root with children D and E. Tree: A(B(D, E), C).

Real-life example

When a compiler reads a + b × c, it builds an expression tree. Postorder traversal of that tree gives a b c × +, which a stack can evaluate. Inorder gives back the normal expression.

Figure: Binary tree traversals: inorder, preorder and postorder
Figure: Binary tree traversals: inorder, preorder and postorder

Same or opposite: preorder and postorder

PointPreorderPostorderSame or opposite
Root visitedFirstLastOpposite
OrderRoot, left, rightLeft, right, rootOpposite
Expression tree givesPrefix formPostfix formOpposite
Visits every node onceYesYesSame

Exam tip. Draw the tree before writing any order. The last item of postorder (first of preorder) is the root.

Back to the topic list

Q7. Stack: operations and implementation using array and linked list

Asked 7 times in 2020, 2022, 2023, 2024, 2025 · Unit 2

From the papers

  • “Write an algorithm which reverses the order of elements on stack using one additional stack and some additional variables.” (2020, 2024)
  • “Define Stack as an ADT. Explain the array and linked list implementation of stacks.” (2025)
  • “Write an algorithm for Push and Pop operations on Stack using linked list.” (2024)

The short answer

A stack is a linear structure where insert and delete happen only at the top. The last item pushed is the first popped, so it is LIFO.

Write these points

  1. Operations: push, pop, peek, isEmpty and isFull.
  2. Array: top starts at -1. Push on a full stack is overflow. Pop on an empty stack is underflow.
  3. Linked list: top is a head pointer. Push inserts at the beginning and pop deletes the first node.
  4. Uses: expression conversion, recursion, bracket matching, undo and DFS.

Steps

  1. push(x): if top == MAX-1 print overflow. Else top = top + 1, S[top] = x.
  2. pop(): if top == -1 print underflow. Else x = S[top], top = top - 1, return x.
  3. List push: new->next = top, top = new. List pop: temp = top, top = top->next, free(temp).

Array stack of size 4.

Push 5, 8, 3: top = 2.

Pop returns 3 and top = 1.

Push 9, then 7: top = 3 and the stack holds 5, 8, 9, 7.

Push 1: top + 1 = 4 = size, so the push fails with overflow.

Real-life example

The undo button in a text editor is a stack. Every change is pushed. Pressing undo pops the last change first. A pile of plates in a canteen works the same way.

Figure: Stack: operations and implementation using array and linked list
Figure: Stack: operations and implementation using array and linked list

Same or opposite: array and linked list stack

PointArray stackLinked list stackSame or opposite
SizeFixedGrows at run timeOpposite
OverflowWhen the array is fullOnly when memory runs outOpposite
Push and pop timeO(1)O(1)Same
Extra memoryNoneOne pointer per nodeOpposite

Exam tip. Write the overflow and underflow checks. Say LIFO and give one application.

Back to the topic list

Q8. Graph traversal: BFS and DFS

Asked 7 times in 2020, 2022, 2023, 2024, 2025 · Unit 4

From the papers

  • “Differentiate between Depth first search and Breadth First search algorithm.” (2020, 2024)
  • “Describe the Depth First Search (DFS) and Breadth First Search (BFS) algorithms for graph traversal with examples.” (2025)
  • “Write algorithms for DFS and BFS traversal on a graph.” (2023)

The short answer

Graph traversal visits every reachable vertex once. BFS goes level by level with a queue, while DFS goes deep first with a stack or recursion and then backtracks.

Write these points

  1. Both need a visited mark per vertex. Time is O(V + E) with an adjacency list.
  2. BFS finds the fewest-edge path in an unweighted graph. DFS finds cycles and connected components.
  3. In the picture neighbours are taken in increasing order. BFS gives 1 2 3 4 5 6. DFS gives 1 2 4 5 6 3.
BFSDFS
UsesQueueStack or recursion
OrderLevel by levelDeep, then back
Shortest pathYes (unweighted)No

Steps

  1. BFS: mark s and enqueue it. While the queue is not empty: u = dequeue, visit u, mark and enqueue each unvisited neighbour.
  2. DFS(u): mark u, visit u, call DFS(v) for each unvisited neighbour v.

BFS and DFS from A.

Edges: A to B and C, B to D and E, C to F, E to F.

BFS with a queue: visit A, then B and C, then D, E and F. Order A B C D E F.

DFS going deep first: A, B, D, back to B, then E, F, back up, then C. Order A B D E F C.

F is visited once in both, because it is marked when first reached.

Real-life example

LinkedIn shows 1st, 2nd and 3rd degree connections. Finding them is BFS: first your friends, then their friends. Solving a maze by following one path to its end and then backtracking is DFS.

Figure: Graph traversal: BFS and DFS
Figure: Graph traversal: BFS and DFS

Same or opposite: BFS and DFS

PointBFSDFSSame or opposite
UsesQueueStack or recursionOpposite
OrderLevel by levelDeep first, then backOpposite
Time with adjacency listO(V + E)O(V + E)Same
Shortest path (unweighted)YesNoOpposite

Exam tip. Show the queue or stack at each step. State the start vertex and neighbour order.

Back to the topic list

Q9. Searching: sequential and binary search

Asked 7 times in 2020, 2022, 2023, 2024, 2025 · Unit 5

From the papers

  • “Explain sequential search and simulate it for the following data 4, 21, 36, 14, 62, 91, 8, 22, 81, 77, 10.” (2022, 2023, 2024)
  • “Apply Binary search to search 36 in following list :” (2023, 2024)
  • “Explain Binary Search with an example.” (2025)

The short answer

Searching finds the position of a key in a list, or reports that it is absent.

Write these points

  1. Sequential search checks each item from the first. It works on any list. Worst case O(n).
  2. Binary search needs a sorted array. It compares the key with the middle item and drops half the list each time. Time O(log n).
SequentialBinary
Sorted list neededNoYes
Worst caseO(n)O(log n)

Steps

  1. Binary search: low = 0, high = n-1. While low <= high: mid = (low + high) / 2.
  2. If A[mid] == key return mid. If key < A[mid] then high = mid-1. Else low = mid+1.

Example.

Binary search in 4 8 10 14 21 22 36 62 77 81 91 for key 36. Mid 5 gives 22, so go right.

Mid 8 gives 77, so go left. Mid 6 gives 36: found at index 6 in 3 steps.

Sequential search in 4 21 36 14 62 91 8 22 81 77 10 finds 36 at the 3rd place.

Real-life example

To find a word in a dictionary you open the middle and check whether the word comes before or after. Then you drop half the book. That is binary search. Looking for a name in an unsorted attendance sheet is sequential search.

Figure: Searching: sequential and binary search
Figure: Searching: sequential and binary search

Same or opposite: sequential and binary search

PointSequentialBinarySame or opposite
Sorted data neededNoYesOpposite
Worst caseO(n)O(log n)Opposite
Works on a linked listYesNot efficientlyOpposite
Returns the position of the keyYesYesSame

Exam tip. Show low, high and mid at each step. Binary search works only on sorted data.

Back to the topic list

Q10. Sorting: bubble sort, shell sort and merge sort

Asked 6 times in 2020, 2022, 2023, 2024 · Unit 5

From the papers

  • “Explain shell sort algorithm and simulate it for the following data 35, 33, 42, 10, 14, 19, 27, 44.” (2022, 2023, 2024)
  • “Explain Multiway Merge sort with an example.” (2024)
  • “Sort the following list of elements 30, 56, 78, 99, 12, 43, 10, 24, 85 by using merge sort.” (2023)

The short answer

Sorting arranges items in order. It makes searching faster.

Write these points

  1. Bubble sort swaps neighbours that are out of order. Each pass moves the largest item to the end. At most n-1 passes. O(n^2), stable.
  2. Shell sort is insertion sort on items a gap apart. Start with gap n/2 and halve it until it is 1.
  3. Merge sort splits the list in halves, sorts each and merges them. O(n log n) always, needs O(n) extra space, stable.
SortBestWorstStable
BubbleO(n)O(n^2)Yes
ShellO(n log n)O(n^2)No
MergeO(n log n)O(n log n)Yes

Steps

  1. Bubble: for i = 0 to n-2, for j = 0 to n-2-i, if A[j] > A[j+1] swap.
  2. Shell on 35 33 42 10 14 19 27 44: gap 4 gives 14 19 27 10 35 33 42 44. Gap 2 gives 14 10 27 19 35 33 42 44. Gap 1 gives 10 14 19 27 33 35 42 44.

Bubble sort and merge sort.

Bubble sort 5 1 4 2 8. Pass 1 gives 1 4 2 5 8. Pass 2 gives 1 2 4 5 8.

Pass 3 makes no swap, so the sort stops early.

Merge sort 38 27 43 3: split into 38 27 and 43 3, then sort each half to 27 38 and 3 43.

Merge the halves: 3, 27, 38, 43.

Real-life example

A teacher arranging answer sheets by roll number may split the pile in two, sort each half, then merge them. That is merge sort. Swapping neighbouring sheets again and again is bubble sort.

Figure: Sorting: bubble sort, shell sort and merge sort
Figure: Sorting: bubble sort, shell sort and merge sort

Same or opposite: bubble sort and merge sort

PointBubble sortMerge sortSame or opposite
Worst timeO(n²)O(n log n)Opposite
Extra spaceO(1)O(n)Opposite
StableYesYesSame
MethodSwap neighboursDivide and mergeOpposite

Exam tip. Show the list after every pass or gap. State best and worst time.

Back to the topic list

Q11. Hashing: hash functions and collision handling

Asked 6 times in 2020, 2022, 2023, 2024, 2025 · Unit 5

From the papers

  • “Hashing” (2022, 2024)
  • “Linear Probing and Chaining” (2025)
  • “Hashing and Indexing” (2024)

The short answer

Hashing stores a key at the index h(key), so search, insert and delete take about O(1) time. A collision is two keys with the same index.

Write these points

  1. Division method: h(k) = k mod m, with m a prime. Others: mid square, folding and digit extraction.
  2. Chaining keeps a linked list in each slot. Open addressing keeps keys in the table: linear probing tries h+1, h+2, quadratic probing tries h+i^2, double hashing uses a second function.
  3. Indexing maps a key to the place of its record, so the whole file need not be scanned.
Keyh = k mod 7Slot after linear probing
5011
70000
7666
8512 (1 taken)
9213 (1, 2 taken)
7334 (3 taken)
10135 (3, 4 taken)

Example.

Size 7, keys 50 700 76 85 92 73 101, h = k mod 7. Chaining is in the picture. Linear probing gives the table below.

  • Good hash function: quick to compute, spreads keys evenly, uses the whole key.
  • Load factor α = keys / table size. Keep it below about 0.7 for open addressing.

Real-life example

A school locker room gives each student locker number = roll number mod 100. Two students with roll 105 and 205 get the same locker. That clash is a collision. The school must decide where the second one goes.

Figure: Hashing: hash functions and collision handling
Figure: Hashing: hash functions and collision handling

Same or opposite: chaining and linear probing

PointChainingLinear probingSame or opposite
Where clashing keys goA list in the same slotThe next free slotOpposite
Table can hold more keys than slotsYesNoOpposite
ClusteringNoYesOpposite
Average search near O(1)YesYesSame

Exam tip. Show each key with its hash value and final slot. Name the collision method you use.

Back to the topic list

Q12. Binary search tree: search, insert and delete

Asked 5 times in 2020, 2022, 2024 · Unit 3

From the papers

  • “Write a 'C' program, how to insert and delete elements in the Binary search tree?” (2022, 2024)
  • “Create a binary search tree for the following numbers 45, 26, 10, 60, 70, 30, 40.” (2024)
  • “What is a binary search tree? Write down its properties. Suggest an example.” (2020)

The short answer

A binary search tree (BST) keeps smaller keys in the left subtree and larger keys in the right subtree of every node. Its inorder traversal is sorted.

Write these points

  1. Search and insert go left or right by comparing the key. A new key becomes a leaf.
  2. Delete: a leaf is removed. A node with one child is replaced by it. A node with two children takes its inorder successor value, then the successor is deleted.
  3. Time is O(log n) for a balanced tree and O(n) for a skewed tree.
  4. Deleting 26 in the picture puts 30 in its place and 40 moves up.

Steps

  1. insert(t, key): if t == NULL return a new node. If key < t->data then t->left = insert(t->left, key). Else t->right = insert(t->right, key). Return t.

Build a BST, search it, delete a node.

Insert 50, 30, 70, 20, 40, 60, 80. Inorder traversal gives 20 30 40 50 60 70 80.

Search 60: 50 (go right), 70 (go left), 60 found in 3 comparisons.

Delete 30, which has two children. Its inorder successor 40 takes its place.

The tree becomes 50 with left child 40 (child 20) and right child 70 (children 60, 80).

Real-life example

A phone contact list kept as a BST lets the phone find 'Ravi' by going left or right at each name. Each step cuts the remaining contacts, so even a long list is searched quickly.

Figure: Binary search tree: search, insert and delete
Figure: Binary search tree: search, insert and delete

Same or opposite: BST and plain binary tree

PointBSTBinary treeSame or opposite
Order ruleLeft < root < rightNoneOpposite
Search timeO(h)O(n)Opposite
Inorder traversal givesSorted orderAny orderOpposite
At most two childrenYesYesSame

Exam tip. Compare with the root first. Say the three delete cases.

Back to the topic list

Q13. B tree and B+ tree

Asked 5 times in 2022, 2023, 2024, 2025 · Unit 3

From the papers

  • “B+ Trees” (2022, 2023, 2024, 2025)
  • “Is there any difference between threaded and unthreaded binary tree? What is a B-tree? Explain.” (2023)

The short answer

A B tree of order m is a balanced multiway search tree with at most m children per node and all leaves at one level. A B+ tree keeps all data in linked leaves.

Write these points

  1. Big nodes fill one disk block, so the tree is short and a search needs few disk reads. Databases use it.
  2. Insert in a leaf. On overflow split at the median and move it up. A root split adds one level.
  3. Delete a key. If the node has too few keys, borrow from a sibling or merge.
  4. B* tree keeps nodes at least two thirds full.
B treeB+ tree
Data storedEvery nodeLeaves only
Leaf linksNoYes
Range searchSlowFast

Example.

Order 3: insert 10, 20, 30. The node [10 20 30] overflows. Split at 20: root [20] with children [10] and [30].

Real-life example

Database tables in MySQL are indexed with B+ trees. A query reaches a record in three or four disk reads, even among millions of rows, because each node holds many keys.

Figure: B tree and B+ tree
Figure: B tree and B+ tree

Same or opposite: B tree and B+ tree

PointB treeB+ treeSame or opposite
Data pointers inAll nodesLeaves onlyOpposite
Leaves linkedNoYesOpposite
Range queriesSlowerFastOpposite
Balanced, all leaves at one levelYesYesSame

Exam tip. Draw the tree after every split. State the order of the tree.

Back to the topic list

Q14. AVL tree and its rotations

Asked 4 times in 2023, 2024, 2025 · Unit 3

From the papers

  • “What are AVL Trees? Explain the four types of rotations (LL, RR, LR, RL) used to balance an AVL tree.” (2025)
  • “Describe the algorithms used to perform single and double rotation on AVL tree.” (2024)
  • “Insert the following data keys in the AVL Tree:” (2023)

The short answer

An AVL tree is a BST in which every node has a balance factor (left height minus right height) of -1, 0 or +1. A rotation restores balance after insert or delete.

Write these points

  1. Height stays O(log n), so search, insert and delete take O(log n).
  2. Rotate at the first unbalanced node on the path back from the new node.
  3. LR case: rotate left at the child, then right at the node. RL is the mirror.
CaseNew key goesFix
LLLeft of left childRight rotation
RRRight of right childLeft rotation
LRRight of left childLeft, then right
RLLeft of right childRight, then left

Steps

  1. Right rotation at x: y = x->left, x->left = y->right, y->right = x, return y.
  2. LR example: insert 50, 40, 45. Rotate left at 40, then right at 50. Root is 45 with children 40 and 50.

Two rotations.

Insert 10, 20, 30. Node 10 gets balance factor −2 with a right-right shape.

One left rotation at 10 makes 20 the root with children 10 and 30.

Insert 25, then 28. Node 30 gets balance factor +2 while its child 25 is −1: a left-right case.

Rotate left at 25, then right at 30. Node 28 takes that place with children 25 and 30.

Final tree: 20 with children 10 and 28. Every balance factor is −1, 0 or +1.

Real-life example

If names are added to a BST in alphabetical order, it becomes a long chain and search slows to O(n). An AVL tree rotates after each insert to keep it short, so search stays O(log n).

Figure: AVL tree and its rotations
Figure: AVL tree and its rotations

Same or opposite: AVL tree and BST

PointAVL treeBSTSame or opposite
Balance factor−1, 0 or +1AnyOpposite
Worst searchO(log n)O(n)Opposite
RotationsAfter insert and deleteNoneOpposite
Order rule left < root < rightYesYesSame

Exam tip. Write balance factors after each insert. Name the case before you rotate.

Back to the topic list

Q15. Quick sort with an example

Asked 4 times in 2020, 2023, 2024, 2025 · Unit 5

From the papers

  • “Sort the following elements using quick sort :” (2020, 2023, 2024)
  • “Explain the Quick Sort algorithm with suitable example.” (2025)

The short answer

Quick sort picks a pivot, partitions the list so smaller items are on the left and larger on the right, then sorts both parts recursively.

Write these points

  1. Best and average time O(n log n). Worst time O(n^2), for example a sorted list with the first item as pivot.
  2. It sorts in place, uses O(log n) stack space and is not stable.
CaseTimeWhen
BestO(n log n)Even split
WorstO(n^2)Sorted list, first pivot

Steps

  1. quick(A, lo, hi): if lo < hi then p = partition(A, lo, hi), quick(A, lo, p-1), quick(A, p+1, hi).
  2. Partition: i moves right to an item > pivot, j moves left to an item <= pivot. If i < j swap. When they cross swap the pivot with A[j].
  3. Data 35 33 42 10 14 19 27 44 gives 19 33 27 10 14 | 35 | 42 44. Sorting both parts gives 10 14 19 27 33 35 42 44.

One partition step.

List 35 50 15 25 80 20 90 45 with the last item 45 as pivot.

Move each item ≤ 45 to the left part: 35, 15, 25 and 20 in turn.

Put the pivot after them: 35 15 25 20 45 50 90 80. The pivot is now in its final place.

Sort 35 15 25 20 and 50 90 80 the same way. Result: 15 20 25 35 45 50 80 90.

Real-life example

Sorting students by height, you pick one student as the pivot. Shorter ones stand on the left, taller on the right. Then you repeat inside each group. That is quick sort.

Figure: Quick sort with an example
Figure: Quick sort with an example

Same or opposite: quick sort and merge sort

PointQuick sortMerge sortSame or opposite
Average timeO(n log n)O(n log n)Same
Worst timeO(n²)O(n log n)Opposite
Extra spaceO(log n) stackO(n)Opposite
StableNoYesOpposite
Divide and conquerYesYesSame

Exam tip. Show the list after each partition. Mention the O(n^2) worst case.

Back to the topic list

How we picked these questions

RGPV teaches Data Structures to 3 branches under one syllabus. Each branch prints its own code on the paper, but the units are the same. So one page and one PDF serve all of them.

We counted every question in the Data Structures papers on this site by topic, from 2020 to 2025. A topic that keeps coming back is a topic RGPV likes, so it sits higher in the table. One branch alone has only a few papers. Counting them together gives a surer list.

Data Structures important questions by branch

CS-303 Data Structures important questions for CSE, Semester 3

CS-303 follows the same RGPV syllabus as the other codes on this page. The 15 topics and answers above are the CS-303 important questions too.

See all 13 CS-303 previous year papers

AD-303 Data Structures important questions for AI & Data Science, Semester 3

AD-303 follows the same RGPV syllabus as the other codes on this page. The 15 topics and answers above are the AD-303 important questions too.

See all 1 AD-303 previous year paper

IS-303 Data Structures important questions for IOT, Semester 3

IS-303 follows the same RGPV syllabus as the other codes on this page. The 15 topics and answers above are the IS-303 important questions too.

See all 9 IS-303 previous year papers

About Data Structures

Data Structures (CS-303) teaches how to store data so a program can use it fast. It is a Semester 3 subject of RGPV B.Tech CSE with five units: linear structures, stacks and queues, trees, graphs and sorting with searching. Code every structure at least once in C, because exam questions test whether you can trace the steps.

Data Structures unit-wise brief

Unit 1: Introduction to data structures

This unit reviews C and introduces data, information and abstract data types. You learn how data sits in memory, how to estimate the cost of an operation, and how arrays and linked lists work, including circular and doubly linked lists. Polynomial handling with a linked list is a classic application, so try it yourself.

Unit 2: Stacks and queues

A stack removes the last item added, and a queue removes the first. The unit covers different ways to build each, multiple stacks, circular queues, double-ended and priority queues, and uses such as converting infix to postfix and evaluating a postfix expression. Trace a postfix example on paper until it feels easy.

Unit 3: Trees

Trees store data in levels. You learn the basic terms, binary search trees with insertion, search and traversal, AVL trees and heaps, and then get an introduction to multi-way trees such as B, B+ and B* trees and red-black trees. Draw the tree after every insertion; rotations are easy to get wrong in your head.

Unit 4: Graphs

A graph links items in any pattern. This unit covers directed and undirected graphs, ways to store them, traversal by depth first and breadth first search, and the minimum spanning tree algorithms of Kruskal and Prim. It also covers Dijkstra's shortest path algorithm. Run each algorithm on a small graph by hand.

Unit 5: Sorting and searching

This unit compares sorting methods: bubble, selection, insertion, shell, quick, merge, heap and radix sort. It then covers sequential and binary search, hashing and indexing, with a case study of how operating systems and databases use these structures. Make a small table of each sort's steps and cost to compare them quickly.

Units follow the RGPV scheme and syllabus, B.Tech Computer Science and Engineering, Semester 3 (AICTE flexible curriculum, batches admitted July 2020 (w.e.f. July 2021)). For the full topic list of each unit, open the Data Structures notes.

Start with the latest papers

Data Structures - Dec 2025

Data Structures - Dec 2024

Data Structures - Jun 2024

See all 13 papers →

Data Structures (CS-303) FAQs

What are the most important topics in Data Structures?

By how often they were asked in the papers on this site: Infix to postfix conversion and postfix evaluation (11 times); Singly and circular linked list: representation and operations (11 times); Queue: simple, circular, priority and double ended queue (9 times); Data structures: classification, ADT, operations and cost (8 times); Minimum spanning tree: Kruskal and Prim algorithms (8 times).

How were these Data Structures important questions chosen?

Each topic was counted from the questions in the past papers listed on this site (2020-2025). Repeated is the number of times the topic came. The counts come from keyword matching and the answers are not teacher-reviewed, so use them together with your syllabus.

Is there a PDF of Data Structures important questions with answers?

Yes. The Paperwala Imp Question & Answer PDF for Data Structures is free to download from this page.

The 15 most repeated topics of Data Structures (CS-303) for RGPV B.Tech CSE semester 3, counted from the previous year papers on this site. The same syllabus is taught under 3 codes: CS-303, AD-303, IS-303. Data Structures is also searched for as CO-303.

Also known as CO-303