Data Structures— Concepts, Formulas & Shortcuts
- Array: O(1) indexed access, O(n) insert/delete in the middle, fixed size.
- Linked list: O(1) insert/delete given the node, O(n) search, no random access.
- Stack is LIFO (push/pop); queue is FIFO (enqueue/dequeue).
- Binary search on a sorted array is O(log n); linear search is O(n).
- Hash table gives O(1) average lookup but O(n) worst case when collisions degenerate.
- Balanced BST (AVL, Red-Black) gives O(log n) search, insert and delete; an unbalanced BST degrades to O(n).
Data Structures Practice Questions with Answers
Attempt each question first, then open the explanation. All 8 questions below are free to read and require no signup.
Q1.Which data structure follows the LIFO principle?
Easy- AQueue
- BStack
- CLinked list
- DTree
Data Structures question 1 of 8+Show Answer & Explanation
Answer: B. Stack
Explanation: A stack removes the most recently added element first — Last In, First Out.
Q2.The time complexity of binary search on a sorted array of n elements is:
Easy- AO(n)
- BO(log n)
- CO(n log n)
- DO(1)
Data Structures question 2 of 8+Show Answer & Explanation
Answer: B. O(log n)
Explanation: Each comparison halves the search space, giving logarithmic time.
Q3.Which data structure is used for Breadth First Search of a graph?
Moderate- AStack
- BQueue
- CHeap
- DTrie
Data Structures question 3 of 8+Show Answer & Explanation
Answer: B. Queue
Explanation: BFS explores level by level, which requires FIFO ordering — hence a queue. DFS uses a stack (or recursion).
Q4.The worst-case time complexity of searching in an unbalanced binary search tree is:
Moderate- AO(1)
- BO(log n)
- CO(n)
- DO(n²)
Data Structures question 4 of 8+Show Answer & Explanation
Answer: C. O(n)
Explanation: If insertions arrive in sorted order the tree degenerates into a linked list, making search linear.
Q5.Which operation is O(1) in an array but O(n) in a singly linked list?
Moderate- AInsertion at head
- BAccess by index
- CDeletion at head
- DTraversal
Data Structures question 5 of 8+Show Answer & Explanation
Answer: B. Access by index
Explanation: Arrays support constant-time random access; a linked list must walk from the head to reach index i.
Q6.A min-heap guarantees that:
Moderate- AThe tree is sorted in-order
- BThe root is the smallest element
- CAll leaves are at the same level
- DSearch takes O(log n)
Data Structures question 6 of 8+Show Answer & Explanation
Answer: B. The root is the smallest element
Explanation: The heap property makes every parent ≤ its children, so the minimum sits at the root. Arbitrary search is still O(n).
Q7.Which sorting algorithm has the best average-case time complexity?
Easy- ABubble sort
- BQuick sort
- CSelection sort
- DInsertion sort
Data Structures question 7 of 8+Show Answer & Explanation
Answer: B. Quick sort
Explanation: Quick sort averages O(n log n); the other three average O(n²).
Q8.A circular queue is preferred over a linear queue because it:
Difficult- AUses less memory per element
- BReuses vacated space at the front
- CAllows random access
- DSorts elements automatically
Data Structures question 8 of 8+Show Answer & Explanation
Answer: B. Reuses vacated space at the front
Explanation: In a linear array queue the front space is wasted after dequeuing. A circular queue wraps the rear index around to reuse it.
Data Structures — Frequently Asked Questions
When should I use a linked list instead of an array?+
When insertions and deletions dominate and you do not need random access — a linked list avoids the O(n) shifting an array requires. If you index frequently or care about cache locality, an array wins.
What is the time complexity of a hash table lookup?+
O(1) on average with a good hash function and load factor. In the worst case, when all keys collide into one bucket, it degrades to O(n) — or O(log n) if the bucket uses a balanced tree.
Cleared the aptitude round? Now grab the role.
Preparation only pays off when you apply. Thousands of internships and fresher jobs across India are live on MyInternships.in right now — free to apply, no consultancy fees.
