Data Structures and Algorithms

📘 DATA STRUCTURES


1️⃣ What is a Data Structure?

🔹 A Data Structure is a method of storing and organizing data so it can be used efficiently.

Example

  • Student names in a list
  • Books arranged in library racks
  • Files stored in folders

Important Definitions

TermMeaning
DataRaw facts (numbers, text, values)
StructureOrganized format
Data StructureWay to store & manage data efficiently

2️⃣ Why Are Data Structures Important?

✔ Efficient data storage
✔ Faster search, insert, delete, sort
✔ Saves time & memory
✔ Improves software performance


3️⃣ Types of Data Structures

TypeDescription
LinearData arranged sequentially
Non-LinearData arranged in branches / hierarchy

📍 4️⃣ Linear Data Structures

A. Array

FeatureDetail
Fast AccessUsing index → arr[2] = value
Fixed SizeCannot expand

✔ Used in: Employee IDs, Roll numbers
📌 Example: [10, 20, 30, 40]


B. Linked List

  • Nodes connected using pointers
    📌 Example → 10 → 20 → 30
FeatureDetail
Flexible sizeCan grow/shrink
Slow accessMust traverse step by step

C. Stack

LIFO – Last In, First Out
📌 Real-life: Stack of plates

OperationMeaning
PushInsert
PopRemove

✔ Used in: Undo, Browser history, Recursion


D. Queue

🚶 FIFO – First In, First Out
📌 Real-life: ATM queue

OperationMeaning
EnqueueInsert
DequeueRemove

✔ Used in: Scheduling, Ticket counters


🌳 5️⃣ Non-Linear Data Structures

A. Tree

  • Hierarchical structure
    📌 Example: Family tree, Folder structure
TermMeaning
RootTop node
ChildNode under another
LeafNo children

B. Graph

  • Nodes & connections
    📌 Example: Railway network, Social network
TermMeaning
Node/VertexPoint (person/place)
EdgeConnection

🔑 6️⃣ Hashing & Hash Table

TermMeaning
HashingFast searching technique
Hash TableStores key-value pairs

📌 Example:
Roll 101 → Ravi
Roll 102 → Sita

✔ Used in: Databases, Passwords


📊 7️⃣ Difference Table

FeatureArrayLinked ListStackQueue
TypeLinearLinearLinearLinear
SizeFixedDynamicDynamicDynamic
AccessFastSlowRestrictedRestricted
LogicIndexPointerLIFOFIFO

🎯 Real-Life Examples

StructureExample
ArrayBook rack
Linked ListTrain coaches
StackUndo
QueueBank queue
TreeFamily tree
GraphRailway map

📌 Most Important Key Lines

LIFO → Stack
FIFO → Queue
Array → Fixed size, continuous memory
Linked List → Nodes + pointers
Tree → Hierarchical
Graph → Relations / connections
Hashing → Fast search

📘 ALGORITHM COMPLEXITY


1️⃣ What is Complexity?

Measures time & memory used by an algorithm as input size increases.

TypeMeaning
Time ComplexityHow long it takes
Space ComplexityHow much memory it needs

2️⃣ Asymptotic Notations

NotationMeaningType
O (Big-O)Upper bound → Worst caseMost asked in exams
Θ (Theta)Exact average
Ω (Omega)Lower bound → Best case

3️⃣ Common Complexity Orders

OrderBig-OExample
BestO(1)Array access
O(log n)Binary Search
O(n)Linear Search
O(n log n)Merge Sort
O(n²)Bubble Sort
WorstO(2ⁿ), O(n!)Recursion/Permutation

📌 Important Memory Chain

O(1) < O(log n) < O(n) < O(n log n) < O(n²) < O(2ⁿ) < O(n!)

4️⃣ Searching

AlgorithmTime Complexity
Linear SearchO(n)
Binary SearchO(log n) (sorted data only)

5️⃣ Sorting

AlgorithmComplexity
Bubble / Selection / InsertionO(n²)
Merge / Quick (avg)O(n log n)

6️⃣ DS Operations Complexity

StructureOperationComplexity
ArrayAccessO(1)
Linked ListSearchO(n)
StackPush/PopO(1)
QueueEnq/DeqO(1)
BST (balanced)Search/Insert/DeleteO(log n)
Hash TableSearch/Insert/DeleteO(1) avg

🟩 10-Second Final Summary

Array → Fast access, fixed size
Linked List → Dynamic
Stack → LIFO
Queue → FIFO
Tree → Hierarchical
Graph → Connections
Hashing → Fast search

Binary Search = O(log n)
Linear Search = O(n)
Bubble/Selection = O(n²)
Merge/Quick = O(n log n)

Complexity measures growth of time & space
Big-O → Worst case


Data Structure MCQ

🧩 TOPIC 1: Basics of Data Structures & Complexity (Q1–Q25)

Q1. A data structure is mainly used to
a) Format the computer
b) Organize and store data
c) Install software
d) Design hardware
Answer: b)

Q2. Which of the following is a linear data structure?
a) Tree
b) Graph
c) Stack
d) Hash table
Answer: c)

Q3. Which of the following is a non-linear data structure?
a) Stack
b) Queue
c) Linked list
d) Tree
Answer: d)

Q4. The main purpose of using data structures is to
a) Increase power consumption
b) Decrease speed
c) Handle data efficiently
d) Reduce memory size of CPU
Answer: c)

Q5. Time complexity refers to
a) Amount of data stored
b) Time taken by an algorithm
c) Memory used by CPU
d) Power used by system
Answer: b)

Q6. Space complexity refers to
a) Time taken by program
b) Bandwidth used
c) Amount of memory required
d) Screen size required
Answer: c)

Q7. In Big-O notation, O(1) means
a) Constant time
b) Linear time
c) Logarithmic time
d) Quadratic time
Answer: a)

Q8. In Big-O notation, O(n) means
a) Constant
b) Linear
c) Exponential
d) Logarithmic
Answer: b)

Q9. Which operation is usually fastest in an array?
a) Search any element
b) Insert in middle
c) Delete in middle
d) Access element by index
Answer: d)

Q10. Which operation is usually fastest in a linked list?
a) Access by index
b) Insert at beginning
c) Search element
d) Delete last element (singly list)
Answer: b)

Q11. Which one is not a linear data structure?
a) Array
b) Stack
c) Queue
d) Binary tree
Answer: d)

Q12. Which is a basic operation of a data structure?
a) Compiling
b) Traversing
c) Printing bill
d) Installing OS
Answer: b)

Q13. Which of the following is used to represent hierarchical data?
a) Stack
b) Queue
c) Tree
d) Array
Answer: c)

Q14. In algorithm analysis, the worst case tells us
a) Minimum time taken
b) Average time taken
c) Maximum time taken
d) Time taken only sometimes
Answer: c)

Q15. Which time complexity is generally considered best?
a) O(n²)
b) O(1)
c) O(n log n)
d) O(n³)
Answer: b)

Q16. Which of these is not a valid time complexity notation?
a) O(n)
b) Θ(n)
c) Φ(n)
d) Ω(n)
Answer: c)

Q17. Data structure choice mainly depends on
a) User’s age
b) Operating system
c) Type of operations needed
d) Monitor size
Answer: c)

Q18. Which field commonly uses data structures?
a) Banking software
b) Operating systems
c) Networks
d) All of the above
Answer: d)

Q19. In memory, data structures are stored in
a) Secondary storage only
b) RAM (main memory)
c) Printer
d) Monitor
Answer: b)

Q20. Which is an example of an abstract data type (ADT)?
a) Integer
b) Float
c) Stack
d) Character
Answer: c)

Q21. Which is an advantage of using proper data structures?
a) Slower processing
b) More bugs
c) Better performance and easier programs
d) No need to test code
Answer: c)

Q22. Which of these is a collection of data with rules on how to access and modify it?
a) Compiler
b) Data structure
c) Router
d) Hard disk
Answer: b)

Q23. Which of the following is not an ADT?
a) Queue
b) Stack
c) Binary tree
d) Keyboard
Answer: d)

Q24. In real applications, data structures are usually combined with
a) Operating systems only
b) Algorithms
c) Mobile phones
d) Antivirus
Answer: b)

Q25. Choosing a wrong data structure can lead to
a) Faster programs
b) Slower and memory-heavy programs
c) Free internet
d) No effect at all
Answer: b)


📚 TOPIC 2: Arrays & Strings (Q26–Q55)

Q26. An array is
a) Collection of different data types
b) Collection of same type elements stored in continuous memory
c) Random collection of files
d) Only used in networks
Answer: b)

Q27. Index of the first element in most programming languages is
a) –1
b) 0
c) 1
d) 2
Answer: b)

Q28. Accessing any element in an array by index takes
a) O(1) time
b) O(n) time
c) O(log n) time
d) O(n²) time
Answer: a)

Q29. What is needed to declare an array?
a) Type of elements only
b) Size only
c) Type and size
d) Operating system name
Answer: c)

Q30. Which of these is not an advantage of arrays?
a) Fast access by index
b) Fixed size
c) Easy to iterate
d) Good cache usage
Answer: b)

Q31. Inserting an element in the middle of an array is
a) Very fast
b) Constant time
c) Slow because shifting is needed
d) Always impossible
Answer: c)

Q32. Deleting an element from an array middle requires
a) No shifting
b) Shifting elements
c) Turning off CPU
d) Adding more RAM
Answer: b)

Q33. Which is best suited to store a fixed list of account types (Saving, Current, NRE, NRO)?
a) Linked list
b) Array
c) Tree
d) Graph
Answer: b)

Q34. A two-dimensional array is mainly used to store
a) Single value
b) Table or matrix
c) Audio
d) Image only
Answer: b)

Q35. If an array has n elements, the last index is
a) n
b) n + 1
c) n – 1
d) 1
Answer: c)

Q36. Which data structure is generally used to represent a simple matrix?
a) Queue
b) Stack
c) 2D array
d) Tree
Answer: c)

Q37. Which of the following is true for arrays?
a) Elements are stored randomly in memory
b) Elements are stored in continuous memory
c) Each element is stored on different disk
d) Only one element can be stored
Answer: b)

Q38. Searching an element one by one in an unsorted array is called
a) Binary search
b) Linear search
c) Hashed search
d) Indexed search
Answer: b)

Q39. The time complexity of linear search in worst case is
a) O(1)
b) O(n)
c) O(log n)
d) O(n²)
Answer: b)

Q40. Binary search on array requires the array to be
a) Unsorted
b) Random
c) Sorted
d) Very large only
Answer: c)

Q41. Time complexity of binary search in worst case is
a) O(1)
b) O(n)
c) O(log n)
d) O(n²)
Answer: c)

Q42. Which symbol is used to access array element in most programming languages?
a) {}
b) []
c) ()
d) <>
Answer: b)

Q43. A character array used to store text is commonly called
a) Integer list
b) String
c) Float list
d) Queue
Answer: b)

Q44. Which operation is not possible directly on arrays?
a) Insert at specified index
b) Access by index
c) Delete and shift
d) Insert in middle with no shifting at all
Answer: d)

Q45. In banking software, a fixed-size list of months (Jan–Dec) is best stored in
a) Array
b) Tree
c) Graph
d) Stack
Answer: a)

Q46. Which type of array is used to represent marks of 5 students in 3 subjects?
a) 1D array
b) 2D array
c) 3D array
d) Linked list
Answer: b)

Q47. If a 1D array has 10 integer elements, how many elements can it store?
a) 1
b) 5
c) 9
d) 10
Answer: d)

Q48. In an array, random access means
a) Access with random number generator
b) Access any element in constant time using index
c) Access only first and last element
d) Access only odd positions
Answer: b)

Q49. Which of the following is disadvantage of arrays?
a) Continuous memory
b) Fixed size at compile time
c) Fast access
d) Simple implementation
Answer: b)

Q50. Which is better for implementing simple lookup tables (like interest rate slabs)?
a) Array
b) Tree
c) Graph
d) Queue
Answer: a)

Q51. The array used to represent monthly balance for an account for 12 months is an example of
a) Non-linear structure
b) Linear structure
c) Tree structure
d) Graph structure
Answer: b)

Q52. What happens if you try to access array[100] in a size 10 array?
a) Always safe
b) It is out of bounds / error
c) Gives 0
d) Automatically resizes
Answer: b)

Q53. Which of the following is true about strings in many languages?
a) They are arrays of characters
b) They are stacks
c) They are queues
d) They are graphs
Answer: a)

Q54. Storing IFSC codes of different branches in a fixed-length list is an example of using
a) Graph
b) Array
c) Tree
d) Stack
Answer: b)

Q55. When we pass an array to a function, usually we pass
a) Copy of entire array
b) Memory address (reference) of first element
c) Only last element
d) No data
Answer: b)


🔗 TOPIC 3: Linked Lists (Q56–Q85)

Q56. A linked list is a collection of
a) Elements stored in continuous memory
b) Nodes connected by pointers
c) Tables and charts
d) Images
Answer: b)

Q57. In a singly linked list, each node contains
a) Data only
b) Pointer only
c) Data and pointer to next node
d) Data and two pointers
Answer: c)

Q58. In a singly linked list, the last node’s next pointer is
a) 0
b) 1
c) NULL
d) –1
Answer: c)

Q59. A doubly linked list node contains
a) One pointer
b) Two pointers (prev and next) and data
c) Only data
d) No pointer
Answer: b)

Q60. Which is not an advantage of linked lists over arrays?
a) Dynamic size
b) Easy insertion and deletion
c) Random access by index
d) No need for continuous memory
Answer: c)

Q61. To insert a node at the beginning of a singly linked list, we need to
a) Change head pointer
b) Traverse full list
c) Delete tail
d) Rebuild list
Answer: a)

Q62. Linked lists are preferred over arrays when
a) We know exact size
b) Frequent insertions and deletions occur
c) No insertion or deletion
d) Only random access needed
Answer: b)

Q63. Which linked list allows traversal in both directions?
a) Singly linked list
b) Doubly linked list
c) Circular singly list
d) Linear array
Answer: b)

Q64. In a circular linked list, last node points to
a) NULL
b) Itself
c) Head (first node)
d) Random node
Answer: c)

Q65. Which is used to implement round-robin scheduling in operating systems?
a) Linear array
b) Stack
c) Circular linked list
d) Tree
Answer: c)

Q66. Time complexity to insert a node at beginning of linked list is
a) O(1)
b) O(n)
c) O(log n)
d) O(n²)
Answer: a)

Q67. Time complexity to access the k-th element in a singly linked list is
a) O(1)
b) O(log n)
c) O(k)
d) O(k²)
Answer: c)

Q68. Which operation is not efficient in linked list compared to array?
a) Insert at beginning
b) Delete at beginning
c) Random access by index
d) Insert after given node
Answer: c)

Q69. To delete a node in singly linked list, we need
a) Only address of node
b) Address of node and previous node
c) Only previous node
d) Only head
Answer: b)

Q70. Head pointer of linked list stores
a) Data of first node
b) Address of first node
c) Address of last node
d) Number of nodes
Answer: b)

Q71. In bank transaction logs, where records are frequently added and removed, a good data structure is
a) Array
b) Linked list
c) Graph
d) Tree
Answer: b)

Q72. Reversing a singly linked list means
a) Changing data
b) Changing next pointers direction
c) Deleting all nodes
d) Sorting nodes
Answer: b)

Q73. Which is true about doubly linked list?
a) Requires more memory per node than singly list
b) Allows only forward traversal
c) Does not allow deletion
d) Cannot be circular
Answer: a)

Q74. Which linked list is best when we mostly insert and delete at both ends?
a) Singly linear list
b) Doubly linked list
c) Circular doubly linked list
d) Array
Answer: c)

Q75. In a linked list, insertion at the end requires
a) Head only (if tail not kept)
b) No pointer
c) Only last element’s data
d) Operating system support
Answer: a)

Q76. Which application commonly uses linked list?
a) Implementing adjacency list of graphs
b) Implementing CPU registers
c) Representing pixels on screen
d) Storing one integer
Answer: a)

Q77. A self-referential structure is a structure that
a) Refers to itself as data type
b) Refers to OS
c) Refers to network
d) Refers to monitor
Answer: a)

Q78. In a singly linked list, to insert after a given node, we must
a) Change next of given node and new node
b) Change head only
c) Delete previous node
d) Start new list
Answer: a)

Q79. The main disadvantage of linked list over array in banks’ core code is
a) Dynamic size
b) No random access / cache unfriendly
c) Easy insertion
d) Less fragmentation
Answer: b)

Q80. A linked list where each node has two pointers and last node’s next = head and head’s prev = last is
a) Singly list
b) Circular singly list
c) Circular doubly linked list
d) Array list
Answer: c)

Q81. What will be the condition for empty singly linked list?
a) head = NULL
b) head = 0
c) head = 1
d) head = –1
Answer: a)

Q82. To search for an element in linked list, we
a) Use binary search
b) Use random function
c) Traverse node by node
d) Use hash table only
Answer: c)

Q83. If linked list has n nodes, how many NULL references does a singly linear list have?
a) 0
b) 1
c) 2
d) n
Answer: b)

Q84. Which operation is easier in linked list than in array?
a) Increase fixed size
b) Insert in middle
c) Random access
d) Indexing
Answer: b)

Q85. Which linked list variant is best for implementing browser forward/backward history?
a) Singly list
b) Doubly list
c) Queue
d) Stack only
Answer: b)


🧱 TOPIC 4: Stacks (Q86–Q110)

Q86. A stack works on which principle?
a) FIFO
b) LIFO
c) FILO
d) Random
Answer: b)

Q87. Example of stack in real life is
a) Queue at ATM
b) Stack of plates
c) Student attendance register
d) Railway timetable
Answer: b)

Q88. Basic operations of stack are
a) Insert and delete
b) Push and pop
c) Enqueue and dequeue
d) Add and remove index
Answer: b)

Q89. To add an element to stack we use
a) pop()
b) push()
c) insert()
d) enqueue()
Answer: b)

Q90. To remove top element of stack we use
a) pop()
b) push()
c) delete()
d) dequeue()
Answer: a)

Q91. Stack is most suitable to implement
a) Recursion
b) BFS
c) Hash table
d) Adjacency list
Answer: a)

Q92. Which data structure is used for function call management in many languages?
a) Queue
b) Stack
c) Graph
d) Tree
Answer: b)

Q93. Which condition indicates stack overflow (array implementation)?
a) top = –1
b) top = 0
c) top = maxSize – 1
d) top = NULL
Answer: c)

Q94. Which indicates stack underflow?
a) top = –1
b) top = 0
c) top = maxSize – 1
d) top = 1
Answer: a)

Q95. Operation to only see top element without removing it is
a) peek / top
b) pop
c) push
d) scan
Answer: a)

Q96. Stacks are used to convert
a) Binary to decimal
b) Infix expression to postfix
c) Images to text
d) Graph to tree
Answer: b)

Q97. In a text editor, Undo operation is best implemented using
a) Queue
b) Stack
c) Linked list
d) Graph
Answer: b)

Q98. If we push elements 1, 2, 3, 4 in this order and pop once, which element is removed?
a) 1
b) 2
c) 3
d) 4
Answer: d)

Q99. Stacks are used in
a) Parentheses matching
b) Evaluating postfix expressions
c) Backtracking algorithms
d) All of the above
Answer: d)

Q100. Array-based stack has disadvantage of
a) Overflow at fixed size
b) No underflow
c) Unlimited capacity
d) Not usable in OS
Answer: a)

Q101. Linked list-based stack has advantage of
a) Known fixed size
b) Dynamic growth until memory finishes
c) Faster random access
d) Less code
Answer: b)

Q102. In bank systems, stacks can be used for
a) Managing last transactions viewed in app
b) Fixed deposit list
c) Loan master data
d) ATM queue
Answer: a)

Q103. Time complexity of push and pop operation on stack is
a) O(1)
b) O(n)
c) O(log n)
d) O(n²)
Answer: a)

Q104. Reversing a word using stack means
a) Insert all chars then pop them
b) Sort characters
c) Remove vowels
d) Add numbers
Answer: a)

Q105. Stack is best for
a) Level-order traversal
b) Depth-first search (DFS)
c) Breadth-first search (BFS)
d) Hash indexing
Answer: b)

Q106. Which one is not an application of stack?
a) Expression evaluation
b) Storing recursion calls
c) Reversing a string
d) Managing bank customers in line
Answer: d)

Q107. A stack implemented using linked list stores the top element at
a) Head
b) Tail
c) Middle
d) Random
Answer: a)

Q108. Postfix expression evaluation uses
a) Stack
b) Queue
c) Tree only
d) Graph
Answer: a)

Q109. When a stack is empty, value of top is usually
a) 1
b) –1 or NULL
c) 0
d) Infinity
Answer: b)

Q110. The reverse of LIFO is sometimes written as
a) FILO
b) FOFO
c) FIFI
d) LOFI
Answer: a)


🚏 TOPIC 5: Queues, Deque, Priority Queue (Q111–Q135)

Q111. A queue works on which principle?
a) LIFO
b) FIFO
c) Random order
d) Tree order
Answer: b)

Q112. Real life example of queue is
a) Stack of plates
b) Line of customers at bank counter
c) Recursive calls
d) File system tree
Answer: b)

Q113. Basic operations of queue are
a) Push and pop
b) Enqueue and dequeue
c) Insert and delete at end
d) Open and close
Answer: b)

Q114. Deletion in queue happens at
a) Rear
b) Front
c) Middle
d) Both ends
Answer: b)

Q115. Insertion in queue happens at
a) Rear
b) Front
c) Middle
d) Random place
Answer: a)

Q116. To implement BFS (Breadth First Search) in graphs we use
a) Stack
b) Queue
c) Tree
d) Array only
Answer: b)

Q117. A circular queue is also known as
a) Round queue
b) Ring buffer
c) Linked queue
d) Tree buffer
Answer: b)

Q118. Condition for queue underflow (array implementation) is
a) front = rear
b) front = –1 or queue empty
c) rear = maxSize – 1
d) rear = 0
Answer: b)

Q119. Condition for queue overflow (simple array implementation) is
a) rear = –1
b) front = 0
c) rear = maxSize – 1
d) front = rear
Answer: c)

Q120. In a bank token system, new customer token is
a) Enqueued
b) Popped
c) Pushed
d) Searched
Answer: a)

Q121. In normal queue, if A, B, C, D are inserted in this order and one by one removed, removal order is
a) ABCD
b) DCBA
c) BACD
d) ACBD
Answer: a)

Q122. A deque (double-ended queue) allows
a) Insert only at front
b) Insert only at rear
c) Insert and delete at both ends
d) No deletion
Answer: c)

Q123. Which structure is good to implement a deque?
a) Doubly linked list
b) Tree
c) Graph
d) Stack
Answer: a)

Q124. Priority queue removes element with
a) Lowest priority first
b) Highest priority first
c) Random
d) Middle element
Answer: b) (common convention in exam questions)

Q125. Which is commonly used to implement priority queue efficiently?
a) Stack
b) Heap
c) Array only
d) Graph
Answer: b)

Q126. In banking, a priority queue can be used for
a) Serving VIP customers first
b) Printing passbook
c) Storing fixed deposits
d) Sorting names alphabetically
Answer: a)

Q127. Time complexity of enqueue and dequeue in simple queue (linked list implementation) is
a) O(1)
b) O(log n)
c) O(n)
d) O(n²)
Answer: a)

Q128. Which queue allows insertion at one end and deletion at both ends?
a) Input-restricted deque
b) Output-restricted deque
c) Circular queue
d) Simple queue
Answer: a)

Q129. Which queue allows deletion at one end and insertion at both ends?
a) Input-restricted deque
b) Output-restricted deque
c) Simple queue
d) Priority queue
Answer: b)

Q130. Which data structure is best for printer job scheduling?
a) Stack
b) Queue
c) Tree
d) Graph
Answer: b)

Q131. Which is not a type of queue?
a) Simple queue
b) Circular queue
c) Priority queue
d) Single-ended queue
Answer: d)

Q132. In circular queue, if we increment rear, we do
a) rear = rear + 1
b) rear = (rear + 1) % size
c) rear = rear – 1
d) rear = size
Answer: b)

Q133. Which data structure is used in operating system scheduling (round robin)?
a) Stack
b) Queue / circular queue
c) Tree
d) Graph
Answer: b)

Q134. For BFS traversal of a tree or graph, we must use
a) Stack
b) Queue
c) Hash table
d) Priority stack
Answer: b)

Q135. In bank call center, customers waiting in line is modeled using
a) Stack
b) Queue
c) Tree
d) Graph
Answer: b)


🌳 TOPIC 6: Trees & Binary Search Trees & Heaps (Q136–Q180)

Q136. A tree is
a) Linear data structure
b) Hierarchical data structure
c) Graphical only
d) Always binary
Answer: b)

Q137. Topmost node in a tree is called
a) Leaf
b) Root
c) Child
d) Sibling
Answer: b)

Q138. Node with no children is called
a) Root
b) Leaf node
c) Parent
d) Internal node
Answer: b)

Q139. In a binary tree, each node has at most
a) 1 child
b) 2 children
c) 3 children
d) 4 children
Answer: b)

Q140. In a binary search tree (BST), left child key is
a) Greater than parent
b) Less than parent
c) Equal to parent
d) Unrelated
Answer: b)

Q141. In BST, right child key is
a) Less than parent
b) Greater than parent
c) Always equal
d) Not fixed
Answer: b)

Q142. Inorder traversal of BST gives elements in
a) Random order
b) Sorted order
c) Reverse order always
d) No order
Answer: b)

Q143. Which is not a tree traversal?
a) Preorder
b) Inorder
c) Postorder
d) Midorder
Answer: d)

Q144. Root-left-right is sequence of
a) Inorder
b) Postorder
c) Preorder
d) Level order
Answer: c)

Q145. Left-root-right is sequence of
a) Preorder
b) Postorder
c) Inorder
d) Level order
Answer: c)

Q146. Left-right-root is sequence of
a) Preorder
b) Postorder
c) Inorder
d) Level order
Answer: b)

Q147. Level order traversal uses which data structure?
a) Stack
b) Queue
c) Tree
d) Graph
Answer: b)

Q148. Height of a tree with single node is generally
a) –1
b) 0
c) 1
d) 2
Answer: b)

Q149. A full binary tree is one in which
a) Every node has 0 or 2 children
b) Every node has 2 children
c) Every level is full except last
d) Only root exists
Answer: a)

Q150. A complete binary tree is one in which
a) All levels except possibly last are full, last level filled from left
b) All nodes have 0 or 2 children
c) Only leaf nodes exist
d) Only one child per node
Answer: a)

Q151. A tree with n nodes has how many edges?
a) n
b) n – 1
c) n + 1
d) 2n
Answer: b)

Q152. Binary search tree is efficient for
a) Sequential search
b) Ordered data search
c) Only insertion
d) Only deletion
Answer: b)

Q153. Average time complexity for search in balanced BST is
a) O(1)
b) O(log n)
c) O(n)
d) O(n²)
Answer: b)

Q154. Worst-case time complexity for search in skewed BST is
a) O(1)
b) O(log n)
c) O(n)
d) O(n²)
Answer: c)

Q155. AVL tree is a
a) Unbalanced tree
b) Self-balancing binary search tree
c) Heap
d) Graph
Answer: b)

Q156. In AVL tree, balance factor is defined as
a) Right height – left height
b) Left height – right height
c) Sum of heights
d) Always 0
Answer: b) (many books use Left – Right)

Q157. Maximum degree (children) of B-tree of order m is
a) m
b) m – 1
c) m + 1
d) 2m
Answer: a)

Q158. Which tree is widely used in databases and file systems?
a) AVL tree
b) B-tree / B+ tree
c) Heap
d) Splay tree
Answer: b)

Q159. In a heap, the structure must be
a) Binary search tree
b) Complete binary tree
c) Linked list
d) Graph
Answer: b)

Q160. In a max heap, the largest element is at
a) Left leaf
b) Root
c) Right child
d) Random node
Answer: b)

Q161. In a min heap, the smallest element is at
a) Root
b) Left child
c) Right child
d) Leaf
Answer: a)

Q162. Which is mainly used to implement priority queue?
a) Stack
b) Max/min heap
c) Linked list
d) Graph
Answer: b)

Q163. Heap sort algorithm is based on which data structure?
a) Stack
b) Heap
c) Graph
d) Queue
Answer: b)

Q164. Which traversal is used for prefix expression from expression tree?
a) Inorder
b) Preorder
c) Postorder
d) Level order
Answer: b)

Q165. Which traversal is used for postfix expression from expression tree?
a) Inorder
b) Preorder
c) Postorder
d) Level order
Answer: c)

Q166. Binary search works on
a) Any tree
b) Binary search tree / sorted array
c) Graph
d) Hash table
Answer: b)

Q167. A node with both left and right child is called
a) Leaf
b) Internal node
c) Root
d) Child node
Answer: b)

Q168. If a binary tree has height h, maximum number of nodes is
a) 2^h – 1
b) 2^(h+1) – 1
c) h²
d) h
Answer: b)

Q169. In banking, tree structures are useful in
a) Representing hierarchical branch network
b) Linear customer list only
c) Random number generation
d) Screen brightness control
Answer: a)

Q170. Inorder traversal of BST having keys [10, 5, 15] gives
a) 10, 5, 15
b) 5, 10, 15
c) 15, 10, 5
d) 10, 15, 5
Answer: b)

Q171. A degenerate (skewed) tree behaves like
a) Graph
b) Linked list
c) Stack
d) Queue
Answer: b)

Q172. In heap, inserting a new element requires
a) Place at end and percolate up
b) Place at root and percolate down only
c) Random place
d) Sorting entire tree
Answer: a)

Q173. In heap, deleting root element involves
a) Remove root, place last element at root, heapify down
b) Delete all children
c) Only decrease key
d) No operation
Answer: a)

Q174. Heaps are especially good when we need
a) Fast search by exact key
b) Fast access to min or max
c) Fast insertion and deletion anywhere
d) Random traversal
Answer: b)

Q175. Which tree is always height-balanced with balance factor –1, 0, or 1?
a) BST
b) AVL tree
c) Heap
d) B-tree
Answer: b)

Q176. Level order traversal of tree uses
a) Stack (DFS)
b) Queue (BFS)
c) Heap
d) Array only
Answer: b)

Q177. Which of these is not a self-balancing BST?
a) AVL tree
b) Red-black tree
c) Splay tree
d) Simple skewed BST
Answer: d)

Q178. In banking, a BST could be used to store
a) Customers sorted by account number
b) Only passbook pages
c) Only fixed deposits
d) Only ATM pins
Answer: a)

Q179. For searching in huge sorted datasets, which tree is preferred?
a) Simple binary tree
b) B-tree / B+ tree
c) Linked list
d) Stack
Answer: b)

Q180. Which tree ensures all leaf nodes are at the same level?
a) Complete binary tree (not always)
b) Perfect binary tree
c) Skewed tree
d) Linked tree
Answer: b)


🌐 TOPIC 7: Graphs (Q181–Q205)

Q181. A graph consists of
a) Nodes only
b) Nodes and edges
c) Only edges
d) Arrays only
Answer: b)

Q182. In graph theory, nodes are called
a) Vertices
b) Points
c) Circles
d) Lines
Answer: a)

Q183. Edges in graph represent
a) Memory blocks
b) Connections/relations between nodes
c) Banks only
d) CPU units
Answer: b)

Q184. A graph where edges have direction is called
a) Undirected graph
b) Directed graph (digraph)
c) Mixed graph
d) Tree
Answer: b)

Q185. Graph used for representing cities and roads is usually
a) Tree
b) Graph
c) Stack
d) Queue
Answer: b)

Q186. BFS (Breadth First Search) uses which data structure?
a) Stack
b) Queue
c) Tree
d) Heap
Answer: b)

Q187. DFS (Depth First Search) uses which data structure?
a) Stack or recursion
b) Queue
c) Deque
d) Priority queue
Answer: a)

Q188. Shortest path algorithms (like Dijkstra) are used on
a) Stacks
b) Queues
c) Graphs
d) Heaps only
Answer: c)

Q189. A complete graph is one in which
a) No edges
b) Every pair of vertices is connected by an edge
c) Only one node
d) Tree structure
Answer: b)

Q190. Adjacency matrix representation of graph uses
a) 1D array
b) 2D array
c) Linked list only
d) Tree
Answer: b)

Q191. Adjacency list representation of graph uses
a) Array of linked lists
b) Only arrays
c) Only matrices
d) Stack only
Answer: a)

Q192. Which representation of sparse graph is more memory efficient?
a) Adjacency matrix
b) Adjacency list
c) Both same
d) Tree
Answer: b)

Q193. Which traversal is better to detect shortest path in unweighted graph?
a) DFS
b) BFS
c) Inorder
d) Preorder
Answer: b)

Q194. A cycle in graph means
a) Path that ends at different node
b) Path that starts and ends at same node
c) No edges
d) No nodes
Answer: b)

Q195. A tree is a special case of graph which is
a) Connected and acyclic
b) Disconnected and cyclic
c) Only cyclic
d) Complete
Answer: a)

Q196. In banking, graphs can be used to model
a) Network of ATMs and branches
b) Stack of currency notes
c) Queue at counter
d) Fixed deposit list
Answer: a)

Q197. Which algorithm is used for minimum spanning tree (MST)?
a) Dijkstra
b) Kruskal / Prim
c) BFS
d) DFS
Answer: b)

Q198. Weighted graph means edges
a) Have no meaning
b) Have associated values like cost, distance
c) Are only 0 or 1
d) Have only direction
Answer: b)

Q199. For detecting if graph is connected we can use
a) BFS or DFS
b) Only stack
c) Only queue
d) Only heap
Answer: a)

Q200. In adjacency matrix of n vertices, space used is
a) O(n)
b) O(n²)
c) O(log n)
d) O(1)
Answer: b)

Q201. In adjacency list of n vertices, space used is
a) O(n + e) where e is edges
b) O(n²)
c) O(1)
d) O(log n)
Answer: a)

Q202. BFS is best when we need
a) Deep search
b) Shallow search / shortest path in unweighted graph
c) Random traversal
d) Inorder traversal
Answer: b)

Q203. DFS is best used in
a) Topological sorting
b) Round robin scheduling
c) Banking queues
d) Printing passbook
Answer: a)

Q204. A directed acyclic graph (DAG) is used in
a) Task scheduling
b) Stacks
c) Queues
d) Deques
Answer: a)

Q205. Graph algorithms are important in banking mainly for
a) Cheque printing
b) Network routing, fraud detection patterns
c) ATM cash counting
d) Loan entry
Answer: b)


🔑 TOPIC 8: Hashing, Searching & Sorting (Q206–Q225)

Q206. Hashing is mainly used for
a) Drawing graphs
b) Fast searching using key
c) Printing reports
d) Sorting data
Answer: b)

Q207. Hash table stores elements as
a) Index only
b) Key–value pairs
c) Only values
d) Only keys
Answer: b)

Q208. A hash function maps key to
a) Value
b) Index in table
c) Linked list
d) Tree
Answer: b)

Q209. Collision in hash table means
a) Two keys get same hash index
b) Table got deleted
c) Code crashed
d) OS error
Answer: a)

Q210. Which is not a collision resolution technique?
a) Chaining
b) Linear probing
c) Quadratic probing
d) Bubble probing
Answer: d)

Q211. In chaining, each table index stores
a) Single value only
b) Linked list of entries
c) Heap
d) Tree always
Answer: b)

Q212. Average time complexity for search in good hash table is
a) O(1)
b) O(log n)
c) O(n)
d) O(n²)
Answer: a)

Q213. Binary search can be applied only when
a) Data is unsorted
b) Data is sorted
c) Data is in tree
d) Data is in hash table
Answer: b)

Q214. Linear search in array of n elements takes worst time
a) O(1)
b) O(log n)
c) O(n)
d) O(n²)
Answer: c)

Q215. Bubble sort worst-case complexity is
a) O(1)
b) O(n)
c) O(n log n)
d) O(n²)
Answer: d)

Q216. Which sorting is more efficient on large data on average?
a) Bubble sort
b) Selection sort
c) Insertion sort
d) Merge sort / Quick sort
Answer: d)

Q217. Merge sort uses which technique?
a) Dynamic programming
b) Divide and conquer
c) Greedy
d) Backtracking
Answer: b)

Q218. Quick sort worst-case complexity is
a) O(n)
b) O(n log n)
c) O(n²)
d) O(log n)
Answer: c)

Q219. Counting sort is good when
a) Keys are in small range
b) Keys are huge random strings
c) Data is always sorted
d) Data is graph
Answer: a)

Q220. Stable sorting algorithm means
a) Keeps equal keys in same relative order
b) Uses less memory
c) Is faster
d) Uses stack
Answer: a)

Q221. In banking, hashing is useful in
a) Indexing customer records
b) Printing passbook
c) ATM machine camera
d) Counting currency manually
Answer: a)

Q222. Sorting all customers by name is typical use of
a) Sort algorithm
b) Hashing only
c) Queue
d) Stack
Answer: a)

Q223. Searching a customer by account number in sorted file uses
a) Binary search
b) Linear search only
c) DFS
d) BFS
Answer: a)

Q224. Which search is better when number of records is huge and sorted?
a) Linear search
b) Binary search
c) Random search
d) Hash only
Answer: b)

Q225. To avoid too many collisions, we should
a) Use very small hash table
b) Use good hash function and proper table size
c) Use no hash function
d) Use only arrays
Answer: b)


🧠 TOPIC 9: Mixed & Application-Based (Q226–Q250)

Q226. Which data structure is best for parantheses matching in expressions?
a) Queue
b) Stack
c) Tree
d) Graph
Answer: b)

Q227. To evaluate arithmetic expression in postfix form, we use
a) Queue
b) Stack
c) Tree only
d) Graph
Answer: b)

Q228. To store recent web pages visited in browser, we mostly use
a) Queue
b) Stack
c) Tree
d) Graph
Answer: b)

Q229. To manage print jobs at a bank branch printer, we use
a) Stack
b) Queue
c) Tree
d) Heap
Answer: b)

Q230. To store hierarchical organization structure of bank (HO → Zones → Regions → Branches), we use
a) Queue
b) Graph
c) Tree
d) Stack
Answer: c)

Q231. To represent friendship network in social app, appropriate structure is
a) Stack
b) Queue
c) Tree
d) Graph
Answer: d)

Q232. To maintain sorted collection of keys with frequent search, insert, delete, we use
a) Array only
b) Linked list only
c) Balanced BST (like AVL, Red-black)
d) Stack
Answer: c)

Q233. Which structure is best for undo/redo in bank transaction entry software?
a) Queue
b) Stack (two stacks for undo/redo)
c) Array
d) Heap
Answer: b)

Q234. To model multiple levels of menu in internet banking app, use
a) Tree
b) Stack
c) Queue
d) Hash table
Answer: a)

Q235. For routing packets in bank network (branches, ATMs, data center), algorithms mainly work on
a) Stack
b) Queue
c) Graph
d) Tree only
Answer: c)

Q236. Which combination is correct?
a) Stack → FIFO
b) Queue → LIFO
c) Priority queue → based on priority
d) Tree → Only linear
Answer: c)

Q237. To check if a string is palindrome using data structure, we can use
a) Stack (push chars and compare)
b) Queue only
c) Graph
d) Tree
Answer: a)

Q238. For implementing call center IVR levels (Press 1 → Savings, Press 2 → Loans, etc.) we mostly use
a) Tree
b) Stack
c) Queue
d) Graph
Answer: a)

Q239. In ATM, cash denomination management (notes of 2000, 500, 200, 100) for quick maximum note selection can be done using
a) Heap / priority queue
b) Stack
c) Queue
d) Linked list
Answer: a)

Q240. For storing account statements month-wise (Jan to Dec) where months are fixed, best structure is
a) Array
b) Tree
c) Graph
d) Stack
Answer: a)

Q241. Which mapping is most appropriate?
a) LIFO → Stack, FIFO → Queue
b) LIFO → Queue, FIFO → Stack
c) LIFO → Tree, FIFO → Graph
d) LIFO → Graph, FIFO → Tree
Answer: a)

Q242. If you have to backtrack in maze or puzzle, which data structure helps more?
a) Queue
b) Stack
c) Tree
d) Graph only
Answer: b)

Q243. For storing adjacency information of sparse graph (few edges), we prefer
a) Adjacency matrix
b) Adjacency list
c) Tree
d) Stack
Answer: b)

Q244. In core banking, indexing of records on disk (for fast access) is often done using
a) B-tree / B+ tree
b) Stack
c) Queue
d) Linked list only
Answer: a)

Q245. To simulate CPU job scheduling with different priorities, we use
a) Simple stack
b) Simple queue
c) Priority queue
d) Linked list only
Answer: c)

Q246. Which pair is correctly matched?
a) BFS → Stack
b) DFS → Queue
c) BFS → Queue
d) DFS → Priority queue
Answer: c)

Q247. Which is best pair for expression evaluation and conversion?
a) Stack and queue
b) Stack and tree
c) Queue and tree
d) Heap and queue
Answer: b)

Q248. Which data structure helps to minimize disk access in database index structures?
a) Stack
b) B-tree / B+ tree
c) Simple linked list
d) Queue
Answer: b)

Q249. In real-time fraud detection, suspicious transaction patterns between accounts can be modeled using
a) Stack
b) Queue
c) Graph
d) Array only
Answer: c)

Q250. For exam point of view, which statement is most correct?
a) Knowing only arrays is enough
b) Knowing data structures helps in understanding banking technology, networking, databases, and security systems
c) Data structures are not used in banking
d) Only graphs are used in banks
Answer: b)