BTCS 301-18 Data Structure & Algorithms — important questions
118 questions that keep coming back in Data Structure & Algorithms (BTCS 301-18) PTU exams, picked from 7 past papers. Questions asked more often, and more recently, are listed first.
Most asked
- What is a Queue? Explain its types and operations in detail. — 8 marks · asked 1× (Mid Sem 1 2026)
- Explain Binary Search in detail. Write its algorithm/pseudocode and analyze its best-case, average-case and worst-case time complexity. Consider the sorted array: A = [10, 20, 30, 40, 50, 60, 70]. Search for 60 using Binary Search and show each step with the values of low, high, mid and A[mid]. — 8 marks · asked 1× (Mid Sem 1 2026)
- What is Quick Sort? Explain Quick Sort algorithm using the divide-and-conquer technique. Sort the following elements using Quick Sort and show the partitioning steps: 50, 23, 9, 18, 61, 32, 14, 7. Also analyse its best, average and worst-case time complexity. — 8 marks · asked 1× (Mid Sem 2 2026)
- What is binary tree? Write algorithms for all possible ways of tree traversal. — 8 marks · asked 1× (Mid Sem 2 2026)
- Write an algorithm to delete a node in an array at first location and compute its complexity. — 8 marks · asked 1× (Mid Sem 1 2026)
- Define Big-O, Big-\Omega and Big-\Theta notations. Explain the purpose of each notation and give one suitable example for each. — 4 marks · asked 1× (Mid Sem 1 2026)
- Explain Stack operation PUSH and POP with algorithm and example. — 4 marks · asked 1× (Mid Sem 1 2026)
- What is an AVL tree? Explain the properties of AVL trees and all four types of rotations-LL, RR, LR and RL-with suitable examples. — 4 marks · asked 1× (Mid Sem 2 2026)
- Define Tree.Draw the B-Tree of order 5 of the following data: 92,24,6,7,11,8,,22,4,5,16,19,20,78. — 4 marks · asked 1× (Mid Sem 2 2026)
- What are graph traversal techniques? Explain BFS algorithms with suitable examples. — 4 marks · asked 1× (Mid Sem 2 2026)
Unit 1 — Introduction
- Explain Binary Search in detail. Write its algorithm/pseudocode and analyze its best-case, average-case and worst-case time complexity. Consider the sorted array: A = [10, 20, 30, 40, 50, 60, 70]. Search for 60 using Binary Search and show each step with the values of low, high, mid and A[mid]. — 8 marks · asked 1× (Mid Sem 1 2026)
- Write an algorithm to delete a node in an array at first location and compute its complexity. — 8 marks · asked 1× (Mid Sem 1 2026)
- Define Big-O, Big-\Omega and Big-\Theta notations. Explain the purpose of each notation and give one suitable example for each. — 4 marks · asked 1× (Mid Sem 1 2026)
- Write an algorithm to implement a Binary search using array. Compute its complexity for all three scenarios. — 4 marks · asked 1× (Mid Sem 1 2026)
- Difference between linear and non linear data structure. — 2 marks · asked 1× (Mid Sem 1 2026)
- List the objectives of Data organization using Data structures. — 2 marks · asked 1× (Mid Sem 1 2026)
- List various types of Data Structures and operations performed on it. — 2 marks · asked 1× (Mid Sem 1 2026)
- What does time complexity function of an algorithm represent ? Explain with example. — 2 marks · asked 1× (Mid Sem 1 2026)
- What is the significance of Asymptotic analysis of Algorithm for a problem solution? — 2 marks · asked 1× (Mid Sem 1 2026)
- Find the time complexity of the following code and mention it in Big O int fun(int n) { int count = 0; for(int i = n; i > 0; i /= 2) for(int j = 0; j < i; j++) count += 1; return count; } — 5 marks · asked 1× (End Sem 2025)
- Write pseudocode for adding elements of an array row-wise. Derive its time complexity function and obtain the Big O. — 5 marks · asked 1× (End Sem 2025)
- What is time and space complexity? Give suitable example of each. — 2 marks · asked 1× (End Sem 2025)
- What is Big O notation? Give the Big O of inserting an element in a linear array. — 2 marks · asked 1× (End Sem 2025)
- Given sorted array with 32 elements find the time complexity in worst case (in term of number of comparisons) for linear search, and binary search algorithm. — 2 marks · asked 1× (End Sem 2025)
- List the importance of data organization through data structures. — 2 marks · asked 1× (End Sem 2025)
- What is the drawback in applying Binary search over a given list for search operation? — 2 marks · asked 1× (End Sem 2025)
- Write about Binary Search algorithm with Example and find Time complexity? — 4 marks · asked 1× (Mid Sem 1 2024)
- What is Asymptotic notation? Explain different types of notations? — 2 marks · asked 1× (Mid Sem 1 2024)
- Define Data Structure and list the various operations which are performed on data structure. — 2 marks · asked 1× (Mid Sem 1 2024)
- Give the algorithm of Tower of Hanoi problem with n disks. Derive the total number of moves in this problem. — 5 marks · asked 1× (End Sem 2023)
- Find the time complexity of the following code and mention it in Big O — 5 marks · asked 1× (End Sem 2023)
- Give any two disadvantages of Big O notation. — 2 marks · asked 1× (End Sem 2023)
- What do you mean by Time-Space trade off? Give example. — 2 marks · asked 1× (End Sem 2023)
- Give one advantage and one disadvantage of using Binary search over linear search techniques. — 2 marks · asked 1× (End Sem 2023)
Unit 2 — Stacks and Queues
- What is a Queue? Explain its types and operations in detail. — 8 marks · asked 1× (Mid Sem 1 2026)
- Explain Stack operation PUSH and POP with algorithm and example. — 4 marks · asked 1× (Mid Sem 1 2026)
- What do you mean by condition Rear<Front in circular list. Write pseudocode for deletion in such a list. — 4 marks · asked 1× (Mid Sem 2 2026)
- Write Algorithm for the operations of insertion and deletion over a linear queue. — 4 marks · asked 1× (Mid Sem 2 2026)
- List the various applications of Stack and explain anyone with example. — 4 marks · asked 1× (Mid Sem 1 2026)
- Write pseudocode for the PUSH and POP operations over a stack. — 4 marks · asked 1× (Mid Sem 1 2026)
- What do you mean by Infix, Prefix and Postfix expressions? — 2 marks · asked 1× (Mid Sem 1 2026)
- What is Stack Overflow? — 2 marks · asked 1× (Mid Sem 1 2026)
- What is the purpose of DEQUE? — 2 marks · asked 1× (Mid Sem 2 2026)
- Using the algorithm first convert infix to postfix and then evaluate postfix (give the step by step solution) for evaluating the following expression P P : (12 / (7 - 3)) + (1 + 5) * 2 — 10 marks · asked 1× (End Sem 2025)
- Explain the use of stack for function call and return using suitable example. Why is stack used to implement recurrence functions? — 10 marks · asked 1× (End Sem 2025)
- Suppose you are given an implementation of a queue of integers. The operations that can be performed on the queue are : a) isEmpty(Q) — returns true if the queue is empty, false otherwise. b) delete(Q) — deletes the element at the front of the queue and returns its value. c) insert(Q, i) — inserts the integer i at the rear of the queue. Consider the following function : void f(queue Q){ int i; if (!isEmpty(Q)) { i = delete(Q); f(Q); insert(Q, i); } } What operation is performed by the above function f()? Give step by step explanation with suitable example. — 5 marks · asked 1× (End Sem 2025)
- Explain the concept of insertion in a circular queue giving all possible test cases. — 5 marks · asked 1× (End Sem 2025)
- What do you mean by condition Rear<Front in circular list. Write pseudocode for deletion in such a list. — 4 marks · asked 1× (Mid Sem 2 2025)
- Write Algorithm for the operations of insertion and deletion over a linear queue. — 4 marks · asked 1× (Mid Sem 2 2025)
- Give any two applications of stack data structure. — 2 marks · asked 1× (End Sem 2025)
- What is Big O for enqueue (), dequeue(), isempty(), isfull() operations for array implementation of circular queue? — 2 marks · asked 1× (End Sem 2025)
- List applications of priority queue. — 2 marks · asked 1× (End Sem 2025)
- List the various operations on queue with example. — 2 marks · asked 1× (End Sem 2025)
- Write steps to convert to post fix expression: (8-4)*(2+6)-(3*3). — 2 marks · asked 1× (End Sem 2025)
- What is the purpose of DEQUE? — 2 marks · asked 1× (Mid Sem 2 2025)
- What is stack? Describe the fundamental operation of stack and explain their significance and how they are implemented in a stack data structure. — 8 marks · asked 1× (Mid Sem 1 2024)
- Convert the following infix to prefix (A-B/C)*(X+Y+Z) — 4 marks · asked 1× (Mid Sem 1 2024)
- Evaluate the following postfix expression 4 \ 55 + 62 \ 23 - * — 2 marks · asked 1× (Mid Sem 1 2024)
- Write algorithms to insert and delete an element from array implementation of circular queue. — 5 marks · asked 1× (End Sem 2023)
- What is Big O for push(), pop(), isempty(), isfull() operations for array implementation of stack? — 2 marks · asked 1× (End Sem 2023)
- What is the disadvantage of simple queue over circular queue in array implementation of queue? Give example. — 2 marks · asked 1× (End Sem 2023)
Unit 3 — Linked Lists
- What is binary tree? Write algorithms for all possible ways of tree traversal. — 8 marks · asked 1× (Mid Sem 2 2026)
- What is an AVL tree? Explain the properties of AVL trees and all four types of rotations-LL, RR, LR and RL-with suitable examples. — 4 marks · asked 1× (Mid Sem 2 2026)
- Define Tree.Draw the B-Tree of order 5 of the following data: 92,24,6,7,11,8,,22,4,5,16,19,20,78. — 4 marks · asked 1× (Mid Sem 2 2026)
- Explain with example any two applications of linked list. — 4 marks · asked 1× (Mid Sem 2 2026)
- Define Link list. — 2 marks · asked 1× (Mid Sem 1 2026)
- Define Search Binary Tree. — 2 marks · asked 1× (Mid Sem 2 2026)
- What is header of a linked list? — 2 marks · asked 1× (Mid Sem 2 2026)
- What are the disadvantages of using doubly linked list? — 2 marks · asked 1× (Mid Sem 2 2026)
- What is complete binary tree? — 2 marks · asked 1× (Mid Sem 2 2026)
- Explain all 3 types of traversal algorithms of a binary tree. Consider the following binary tree and give its traversal order for all 3 algorithms. — 8 marks · asked 1× (Mid Sem 2 2025)
- What is binary tree? Write algorithms for all possible ways of tree traversal. — 8 marks · asked 1× (Mid Sem 2 2025)
- Draw the binary search tree of the following 14, 10, 17, 12, 11, 20, 12, 18, 25, 28, 22, 23. Delete the item say 20 from binary search tree and give the whole solution step by step diagrammatically. — 5 marks · asked 1× (End Sem 2025)
- Write an algorithm to remove second last occurrence of an item from single linked list. — 5 marks · asked 1× (End Sem 2025)
- Write pseudocode for the various tree traversal techniques. — 5 marks · asked 1× (End Sem 2025)
- Explain the efficiency of Binary Search Tree during search operation giving example. — 5 marks · asked 1× (End Sem 2025)
- Construct original tree from the given in-order and pre-order traversal * Preorder: [8,5,9,7,1,12,2,4,11,3] * Inorder: [9,5,1,7,2,12,8,4,3,11] — 4 marks · asked 1× (Mid Sem 2 2025)
- Explain the process of deletion from a BST in detail with the help of an example each for scenarios. — 4 marks · asked 1× (Mid Sem 2 2025)
- Define the following: 1. Internal Nodes. 2. Root Node 3. Path in a Tree 4. M-Way tree. — 4 marks · asked 1× (Mid Sem 2 2025)
- Explain with example any two applications of linked list. — 4 marks · asked 1× (Mid Sem 2 2025)
- Give any two advantages of doubly linked list over single linked list. — 2 marks · asked 1× (End Sem 2025)
- What is the advantage of using AVL tree over binary search tree? — 2 marks · asked 1× (End Sem 2025)
- Using example explain the various rotation operations performed on an AVL tree. — 2 marks · asked 1× (End Sem 2025)
- How is height and balance factor of a node calculated in a tree? — 2 marks · asked 1× (End Sem 2025)
- What is the advantage of B+ tree? — 2 marks · asked 1× (End Sem 2025)
- Explain advantage of using linked list over array. — 2 marks · asked 1× (End Sem 2025)
- What is an extended binary tree? Give an example. — 2 marks · asked 1× (Mid Sem 2 2025)
- How can a binary tree be represented in memory using array. Give the array representation of following tree — 2 marks · asked 1× (Mid Sem 2 2025)
- What can be the possible disadvantage of using a BST? — 2 marks · asked 1× (Mid Sem 2 2025)
- What is an AVL tree? Give an example. — 2 marks · asked 1× (Mid Sem 2 2025)
- What is header of a linked list? — 2 marks · asked 1× (Mid Sem 2 2025)
- What are the disadvantages of using doubly linked list? — 2 marks · asked 1× (Mid Sem 2 2025)
- What is complete binary tree? — 2 marks · asked 1× (Mid Sem 2 2025)
- Write an algorithm to delete all the occurrences of an element say 'n' from given linear linked list. — 10 marks · asked 1× (End Sem 2023)
- Define B tree. Draw the B tree of order 5 of the following data: 92, 24, 6, 7, 11, 8, 22, 4, 5, 16, 19, 20, 78 — 10 marks · asked 1× (End Sem 2023)
- What is the need of AVL tree? Explain in detail all types of rotations required to keep the AVL tree balanced after the insert operation. — 8 marks · asked 1× (Mid Sem 2 2023)
- Write the non-recursive algorithm for in-order traversal of binary tree. — 4 marks · asked 1× (Mid Sem 2 2023)
- What is Binary Search Tree? Write algorithm to search for an element in BST. — 4 marks · asked 1× (Mid Sem 2 2023)
- Give any two applications of circular linked list. — 2 marks · asked 1× (End Sem 2023)
- What are AVL trees? How they are different from Binary search tree? — 2 marks · asked 1× (End Sem 2023)
- What is an extended binary tree? Give an example. — 2 marks · asked 1× (Mid Sem 2 2023)
- Define M way Tree. — 2 marks · asked 1× (Mid Sem 2 2023)
- How to insert in a B Tree? Give an example of inserting in B Tree when the keys after insertion exceed the limit and how it is managed. — 2 marks · asked 1× (Mid Sem 2 2023)
- Explain the array representation of binary tree in memory. — 2 marks · asked 1× (Mid Sem 2 2023)
Unit 4 — Sorting and Hashing
- What is Quick Sort? Explain Quick Sort algorithm using the divide-and-conquer technique. Sort the following elements using Quick Sort and show the partitioning steps: 50, 23, 9, 18, 61, 32, 14, 7. Also analyse its best, average and worst-case time complexity. — 8 marks · asked 1× (Mid Sem 2 2026)
- What do you mean by Merge Sort? — 2 marks · asked 1× (Mid Sem 2 2026)
- Illustrate the execution of heap sort (in increasing order) on the sequence 3, 6, 17, 5, 11, 23, 38, 19, 26, 14. — 10 marks · asked 1× (End Sem 2025)
- Explain the need of hash tables and any one solution for collision resolution using suitable example. — 10 marks · asked 1× (End Sem 2025)
- The keys 12, 18, 13, 2, 3, 23, 5 and 15 are inserted into an initially empty hash table of length 10 using open addressing with hash function h(k) = k \bmod 10 and linear probing. What is the resultant hash table (also show intermediate tables)? — 5 marks · asked 1× (End Sem 2025)
- Using the list 24, 5, 35, 17, 12, 16, 21, 10 perform the merge sort step wise. — 5 marks · asked 1× (End Sem 2025)
- Give the worst case time complexity (as Big O) for bubble sort, heap sort, selection sort and merge sort. — 2 marks · asked 1× (End Sem 2025)
- Perform Bubble sort on given array. And also write its Complexity. 47, 55, 12, 88, 55, 47, 88, 12, 30, 99, 23, 65, 71 — 4 marks · asked 1× (Mid Sem 1 2024)
- What is the time Complexity of Insertion Sort in Best case and worst case? — 2 marks · asked 1× (Mid Sem 1 2024)
- The keys 12, 18, 13.2, 3, 23, 5 and 15 are inserted into an initially empty hash table of length 10 using open addressing with hash function h(k) = k \bmod 10 and linear probing. What is the resultant hash table (also show intermediate tables)? — 5 marks · asked 1× (End Sem 2023)
- Illustrate execution of quick-sort (in increasing order) in the sequence 44\ 33\ 11\ 55\ 77\ 90\ 40\ 60\ 99\ 22\ 88 — 5 marks · asked 1× (End Sem 2023)
- What is a heap tree? Write algorithm to delete an element from the heap tree. — 4 marks · asked 1× (Mid Sem 2 2023)
- What is the advantage of merge sort over quick sort? — 2 marks · asked 1× (End Sem 2023)
Unit 5 — Graph
- What are graph traversal techniques? Explain BFS algorithms with suitable examples. — 4 marks · asked 1× (Mid Sem 2 2026)
- Difference between BFS and DFS, — 2 marks · asked 1× (Mid Sem 2 2026)
- Write any 2 applications of graph? — 2 marks · asked 1× (Mid Sem 2 2026)
- What is DFS and BFS traversal of graph? Give the DFS and BFS traversal (starting with node 1) of graph. Show all intermediate steps. — 10 marks · asked 1× (End Sem 2025)
- Explain the data structure used in Breadth first graph traversal. Give the pseudocode for it. — 10 marks · asked 1× (End Sem 2025)
- Give adjacency list and adjacency matrix representations of graph data structures. — 2 marks · asked 1× (End Sem 2025)
- Define complete graph, strongly connected graph. — 2 marks · asked 1× (End Sem 2025)
- How are elements of a graph stored? — 2 marks · asked 1× (End Sem 2025)
- What is DFS and BFS traversal of graph? Give the DFS and BFS traversal (starting with node 0) of graph. Show all intermediate steps — 10 marks · asked 1× (End Sem 2023)
- Define complete graph, strongly connected graph. — 2 marks · asked 1× (End Sem 2023)
- Give adjacency list and adjacency matrix representations of graph data structures. — 2 marks · asked 1× (End Sem 2023)