Data Structures Quiz
Data structures decide how data is stored and how fast it can be used. The questions cover arrays, linked lists, stacks, queues, trees and the typical operations and applications of each.
What this quiz covers
- Arrays and linked lists
- Stacks (LIFO) and queues (FIFO)
- Trees and balanced trees
- Applications such as parentheses matching
Study tip: For each structure, remember one real application; exam questions often ask which structure fits a scenario.
Questions, answers and explanations
1. What is a data structure?
- A programming language
- A collection of algorithms
- A way to store and organize data
- A type of computer hardware
Answer: A way to store and organize data
A data structure is a way of storing and organizing data in memory so that it can be accessed and modified efficiently. Arrays, stacks, queues and trees are common examples.
2. What are the disadvantages of arrays?
- Index value of an array can be negative
- Elements are sequentially accessed
- Data structures like queue or stack cannot be implemented
- There are chances of memory wastage if allocated size is larger than inserted elements
Answer: There are chances of memory wastage if allocated size is larger than inserted elements
A fixed-size array reserves memory in advance; if fewer elements are stored than the allocated size, the unused space is wasted.
3. Which data structure is used for implementing recursion?
- Stack
- Queue
- List
- Array
Answer: Stack
Each recursive call is pushed onto the call stack, and calls return in last-in, first-out order, so recursion relies on a stack.
4. The data structure required to check whether an expression contains balanced parentheses is?
- Queue
- Stack
- Tree
- Array
Answer: Stack
Opening brackets are pushed onto a stack and popped when a matching closing bracket appears; the expression is balanced if the stack ends up empty.
5. Which of the following is NOT an application of Stack?
- Data transfer between asynchronous processes
- Compiler syntax analyzer
- Tracking local variables at runtime
- Parentheses balancing
Answer: Data transfer between asynchronous processes
Stacks are used for syntax analysis in compilers, local variable tracking and parenthesis matching. Data transfer between asynchronous processes uses queues (buffers), not stacks.
6. Which data structure is needed to convert infix notation to postfix notation?
- Tree
- Branch
- Stack
- Queue
Answer: Stack
Converting infix to postfix uses a stack to hold operators until their precedence says they can be output.
7. What is the value of the postfix expression 6 3 2 4 + - * ?
- 74
- -18
- 22
- 40
Answer: -18
Evaluate with a stack: 2 + 4 = 6; 3 − 6 = −3; 6 × (−3) = −18. The expression result is −18.
8. Which data structure is mostly used in a non-recursive implementation of recursion?
- Stack
- Linked List
- Tree
- Queue
Answer: Stack
A recursive function can be turned into a loop by managing an explicit stack that stores the same information the call stack would hold.
9. Which statement about Stack is NOT correct?
- Top of the stack always contains the newest node
- Stack is a FIFO data structure
- Null link is present in the bottom node
- Linked Lists can implement stacks
Answer: Stack is a FIFO data structure
A stack is LIFO (last in, first out), not FIFO. FIFO describes a queue.
10. Which data structure is required for Breadth First Search (BFS)?
- Array
- Stack
- Tree
- Queue
Answer: Queue
BFS visits nodes level by level, so it keeps the next nodes to visit in a queue (first in, first out).
11. The prefix form of A-B/(C*D^E) is?
- -A/B*C^DE
- -A/BC*^DE
- -ABCD*^DE
- -/*^ACBDE
Answer: -A/B*C^DE
Reading the infix form with precedence ^ > * > / > −: C*D^E becomes *C^DE, then B/(…) becomes /B*C^DE, and finally A−… gives -A/B*C^DE.
12. Which statement is NOT true about Linked Lists compared to Arrays?
- Random access is not allowed
- Access is faster than arrays
- Arrays have better cache locality
- Insertion and deletion are easier
Answer: Access is faster than arrays
Linked lists do not support random access, so reaching the n-th element takes O(n); arrays give constant-time access, which is why the statement about faster access is false.
13. Which data structure follows the LIFO principle?
- Tree
- Linked List
- Stack
- Queue
Answer: Stack
A stack follows the Last-In-First-Out (LIFO) principle: the most recently added element is removed first.
14. Which application makes use of a Circular Linked List?
- Recursive function calls
- Undo operation
- Hash Tables
- CPU Scheduling
Answer: CPU Scheduling
A circular linked list has no end, which suits round-robin CPU scheduling where processes are visited repeatedly in a cycle.
15. What is a Bit Array?
- A data structure that compactly stores bits
- Stores arrays of records
- Array with non-continuous elements
- Array where most elements have same value
Answer: A data structure that compactly stores bits
A bit array stores bits compactly, packing many boolean values into machine words to save memory.
16. Which of the following tree data structures is NOT a balanced binary tree?
- Splay Tree
- B-Tree
- AVL Tree
- Red Black Tree
Answer: B-Tree
A B-Tree is a multi-way (not binary) balanced search tree used in databases and file systems, so it is not a balanced binary tree. AVL, Red-Black and Splay trees are binary trees.
17. Which of the following is NOT a type of queue?
- Priority Queue
- Circular Queue
- Single Ended Queue
- Ordinary Queue
Answer: Single Ended Queue
Queue types include ordinary, circular, priority and double-ended queues. A “single ended queue” is not a standard separate type.
18. Which data structure is used for parentheses matching?
- N-ary Tree
- Queue
- Priority Queue
- Stack
Answer: Stack
Parentheses matching pushes each opening symbol on a stack and pops it when the closing symbol arrives, so a stack is used.
19. Which algorithm is used in the Top Tree data structure?
- Backtracking
- Divide and Conquer
- Branch
- Greedy
Answer: Divide and Conquer
Top trees are built and maintained with divide and conquer on a dynamic tree, merging clusters of vertices.
20. Why is a Circular Queue needed?
- Easier computations
- To implement LIFO
- Effective usage of memory
- Delete elements based on priority
Answer: Effective usage of memory
In a linear queue, freed space at the front cannot be reused; a circular queue wraps around, so memory is used effectively.