Data Structures Practice Test
Ten questions on stacks, queues, trees and time complexity for computer science exams and placement preparation.
Answered 0 of 10
Score: 0 / 10
Question 1 of 10
Which data structure follows Last In, First Out (LIFO)?
See the answer
Answer: Stack. A stack removes the most recently added item first, like a pile of plates.
Question 2 of 10
Which data structure follows First In, First Out (FIFO)?
See the answer
Answer: Queue. A queue removes items in the order they were added, like a line at a counter.
Question 3 of 10
What is the worst-case time complexity of binary search on a sorted array?
See the answer
Answer: O(log n). Each step halves the search range, so it takes about log₂ n steps.
Question 4 of 10
What is the time complexity of reading an array element by its index?
See the answer
Answer: O(1). The element's address can be calculated directly from its index, so access takes constant time.
Question 5 of 10
Which data structure is normally used for breadth-first search (BFS) on a graph?
See the answer
Answer: Queue. BFS visits nodes level by level, and a queue keeps them in that order. Depth-first search uses a stack.
Question 6 of 10
Which traversal of a binary search tree gives its values in sorted order?
See the answer
Answer: Inorder. Inorder visits left, node, right. In a binary search tree this gives ascending order.
Question 7 of 10
What is the worst-case time complexity of merge sort?
See the answer
Answer: O(n log n). Merge sort always splits the list in half and merges in linear time, giving O(n log n).
Question 8 of 10
What is the average time complexity of looking up a key in a hash table?
See the answer
Answer: O(1). With a good hash function, lookups take constant time on average. The worst case can reach O(n).
Question 9 of 10
In a min-heap, where is the smallest element?
See the answer
Answer: At the root. Every parent is smaller than or equal to its children, so the minimum is always at the root.
Question 10 of 10
How long does it take to insert a node at the head of a singly linked list?
See the answer
Answer: O(1). You only point the new node at the old head and update the head, so no traversal is needed.
Keep revising Data Structures
More practice tests
- UPSCIndian PolityTen questions on the Constitution, Parliament and fundamental rights, the basics that UPSC and other government exams return to again and again.10 questionsStart
- NEETBiologyTen questions on cells, genetics and human physiology, written to match the NCERT basics that NEET Biology is built on.10 questionsStart
- JEEPhysicsTen questions on mechanics, electricity and optics to check your basics before you move on to harder JEE problems. Take g as 10 m/s² where needed.10 questionsStart
Written by StudyZone for revision. This is not an official exam paper. Always check the latest syllabus from the official exam body.
