A program stores monthly temperatures and frequently retrieves the temperature for a specified day by its numeric position. Which data structure is the most suitable choice?
05 — Data Structures Online Quiz Questions
Use this free practice quiz with 20 questions to review 05 — Data Structures, test your knowledge, and prepare for your next test or exam.
A program pushes A, then B, then C onto a structure and removes one item. Which structure guarantees that C is removed first?
- A
Stack
- B
Queue
- C
Hash table
- D
Adjacency matrix
A service repeatedly retrieves customer records using unique customer IDs and does not need the records in sorted order. Which structure best matches this access pattern?
- A
A tree, because every lookup is guaranteed to be O(log n)
- B
A queue, because records should be processed in arrival order
- C
A hash table, because average-case lookup by key is typically O(1)
- D
A linked list, because it grows without resizing
Which statements correctly describe an adjacency matrix? Select all that apply.
- A
It uses O(V²) space.
- B
It provides O(1) edge lookup.
- C
It stores only the neighbors of each vertex, using O(V + E) space.
- D
It can be useful for dense graphs.
Which statements correctly describe breadth-first search in an unweighted graph? Select all that apply.
- A
It follows one path as far as possible before backtracking.
- B
It explores vertices in layers.
- C
It uses a queue.
- D
It requires weighted edges to find shortest paths.
True or false: Accessing the item at a specified position in a singly linked list is typically O(n).
- A
True
- B
False
True or false: A priority queue always removes the oldest item first, regardless of its priority.
- A
True
- B
False
How many links does each node in a doubly linked list store for navigation? Enter the whole-number count.
What uppercase acronym names the removal rule followed by a stack? Enter the acronym only.
A dictionary must support ordered insertion and lookup while keeping these operations logarithmic as the number of keys grows. Which structure is the best fit?
- A
A balanced binary search tree
- B
A singly linked list
- C
An unsorted array
- D
A stack
True or false: A tree is a connected structure with no cycles.
- A
True
- B
False
Which data structure is the most direct choice when a program frequently retrieves items by their numeric position?
- A
A linked list
- B
An array
- C
A hash table
- D
A graph
A program must remove the most recently added item before any earlier item. Which data structure directly provides this behavior?
- A
Queue
- B
Tree
- C
Stack
- D
Hash table
A singly linked list already provides a reference to the node after which a new node should be inserted. Which statement best describes the insertion operation itself?
- A
The link changes can be O(1).
- B
The insertion is always O(log n).
- C
The insertion is always O(n²).
- D
The insertion requires shifting every later node.
A hash table must store multiple key–value pairs that map to the same bucket. Which collision-handling method stores those entries in a collection associated with that bucket?
- A
Discarding the later key
- B
Chaining
- C
Sorting all keys after every insertion
- D
Replacing the hash function with an index lookup
Which graph traversal explores vertices in layers by using a queue?
A graph has 12 vertices. How many entries does its V × V adjacency matrix contain?
A dynamic array may occasionally allocate a larger block and copy its elements. Even though an individual resize can be expensive, the cost of appending over a long sequence is typically O(1) .
For a sparse graph with V vertices and E edges, an adjacency list requires space.
Explain what asymptotic notation communicates about an operation's efficiency. In your answer, compare O(1), O(log n), and O(n), and explain why an O(log n) operation generally scales better than an O(n) operation for large inputs.