Test your knowledge of stacks, queues, sorting algorithms and complexity!
1. What is dynamic programming?
💡 Dynamic programming solves problems by breaking them into subproblems, solving each once, and storing the results (memoization).
2. What is a stack data structure?
💡 A stack follows LIFO — the last item added is the first to be removed. Like a stack of plates.
3. What is the space complexity of storing n elements in an array?
💡 Storing n elements requires O(n) space — space grows linearly with the number of elements.
4. What is a "heap" data structure?
💡 A heap is a complete binary tree where each parent node is greater (max-heap) or smaller (min-heap) than its children.
5. What is the time complexity of binary search?
💡 Binary search halves the search space each time, giving O(log n) time complexity.
6. What is the difference between BFS and DFS?
💡 BFS (Breadth First Search) explores neighbors level by level. DFS (Depth First Search) goes deep along each branch first.
7. What is a queue data structure?
💡 A queue follows FIFO — the first item added is the first to be removed. Like a queue of people.
8. What is a hash table?
💡 A hash table uses a hash function to compute an index into an array of buckets for fast key-value lookups.
9. What is a linked list?
💡 A linked list consists of nodes where each node contains data and a pointer to the next node.
10. What does LIFO stand for?
💡 LIFO stands for Last In First Out — the principle used by stack data structures.
11. What is a binary tree?
💡 A binary tree is a tree data structure where each node has at most two children: left and right.
12. What is the worst-case time complexity of Bubble Sort?
💡 Bubble Sort compares adjacent elements repeatedly, giving O(n²) in the worst case.
13. What is "recursion" in programming?
💡 Recursion is when a function calls itself with a modified input until it reaches a base case.
14. Which sorting algorithm has the best average time complexity?
💡 Quick Sort has an average time complexity of O(n log n), making it one of the fastest sorting algorithms.
15. What does O(1) time complexity mean?
💡 O(1) means the operation takes the same time regardless of input size. Example: array index access.