Data Structures & Algorithms MCQ
Test your Data Structures & Algorithms knowledge with 100 multiple choice questions covering fundamentals to advanced concepts, with instant feedback and explanations.
What is the time complexity of accessing an element in an array by index?
2Which data structure operates on a Last-In, First-Out (LIFO) principle?
3What is the time complexity of inserting an element at the beginning of a singly linked list?
4Which data structure uses FIFO (First-In, First-Out) ordering?
5What is a binary search tree (BST)?
6What is the worst-case time complexity of binary search?
7What does a hash table use to map keys to values?
8What is a graph?
9Which traversal visits root, left subtree, right subtree in that order?
10What is the space complexity of a recursive function that calls itself n times?
11What is a min-heap?
12What is the time complexity of bubble sort in the worst case?
13What does DFS stand for in graph algorithms?
14What is a doubly linked list?
15Which sorting algorithm has the best average-case time complexity?
16What is an adjacency matrix?
17What is the height of a balanced binary tree with n nodes?
18Which data structure is best for implementing a priority queue?
19What is an inorder traversal of a BST guaranteed to produce?
20What is the average-case time complexity of searching in a hash table?
21What is a circular queue?
22What is the difference between a tree and a graph?
23What operation does a stack use to add an element?
24What is the worst-case time complexity of quicksort?
25What is a deque (double-ended queue)?
26What is a spanning tree of a graph?
27What is the time complexity of merge sort?
28What is a trie (prefix tree)?
29What is the purpose of BFS (Breadth-First Search)?
30What is a self-balancing BST?
31What does Big O notation describe?
32What is a hash collision?
33What is insertion sort best suited for?
34What is the in-degree of a node in a directed graph?
35What does a stack overflow error indicate in recursive algorithms?
36What is the primary advantage of a linked list over an array?
37What is postorder traversal?
38What is amortized time complexity?
39What is the difference between a complete binary tree and a full binary tree?
40What is a sentinel node in a linked list?
What is the time complexity of Dijkstra's algorithm using a binary heap?
2What distinguishes an AVL tree from a standard BST?
3What is dynamic programming?
4What is topological sorting?
5What is the Floyd-Warshall algorithm used for?
6What is the difference between Prim's and Kruskal's algorithms?
7What is a Red-Black tree?
8What is the Bellman-Ford algorithm's advantage over Dijkstra's?
9What is the Union-Find (Disjoint Set Union) data structure used for?
10What is the Knuth-Morris-Pratt (KMP) algorithm used for?
11What is memoization?
12What is the difference between a B-tree and a B+ tree?
13What is a segment tree used for?
14What is the time complexity of heapify (build-heap) for n elements?
15What is the LRU cache and which data structures implement it efficiently?
16What does Kadane's algorithm solve?
17What is a skip list?
18What is the two-pointer technique?
19What is a Fenwick tree (Binary Indexed Tree)?
20What is the sliding window technique?
21What is a cycle in a directed graph, and how is it detected?
22What is the master theorem used for?
23What is the longest common subsequence (LCS) problem?
24What is the 0/1 knapsack problem?
25What is the time complexity of Heap Sort?
26What is a graph's strongly connected component (SCC)?
27What is the difference between greedy algorithms and dynamic programming?
28What is radix sort and when is it faster than comparison-based sorts?
29What problem does the A* algorithm solve?
30What is a monotonic stack?
31Why is a hash map preferred over an array for the "two sum" problem when aiming for O(n) time?
32In a min-heap represented as an array (0-indexed), how do you find the parent of the node at index i?
33What is the key idea behind the "fast and slow pointer" (Floyd's cycle detection) technique on a linked list?
34When choosing between an array-based and a linked-list-based implementation of a stack, what is a key practical tradeoff?
35Why does counting sort run in linear time, and what limits its applicability?
36What is the main advantage of using a hash set to detect duplicates in a collection compared to sorting first?
37In graph traversal, what is the practical effect of using a stack (DFS) versus a queue (BFS) when searching for a target node?
38Why might quicksort be implemented with random pivot selection or median-of-three pivot selection in practice?
39When converting a recursive algorithm into an iterative one using an explicit stack, what is being manually managed?
40Why is binary search not directly applicable to a singly linked list even though the list is sorted?
What is the amortized time complexity of push/pop for a dynamic array (e.g., ArrayList)?
2What is the time complexity of Tarjan's SCC algorithm?
3What is the significance of the Ω notation compared to O notation?
4What is the Aho-Corasick algorithm?
5What is van Emde Boas tree and its advantage?
6What does the P vs NP problem ask?
7What is a suffix array and how is it used?
8What is the concept of cache-oblivious algorithms?
9What is the significance of the lower bound Ω(n log n) for comparison-based sorting?
10What is a treap?
11What is the link-cut tree and what problems does it solve?
12What is heavy-light decomposition?
13What is the persistent data structure?
14What is the Bloom filter?
15What is the difference between NP-hard and NP-complete?
16What is the Fibonacci heap and its advantage over binary heaps?
17What is the Z-algorithm for string processing?
18What is fractional cascading and when is it applied?
19What is the integer sorting lower bound, and why can radix sort break O(n log n)?
20What is the randomized algorithm QuickSelect and its expected time complexity?