Data Structures and Algorithms Interview Questions (DSA MCQs)
Core data structures and algorithms questions asked by product and service companies, with a one-line explanation for each answer.
Q1. Which data structure follows Last In, First Out (LIFO)?
- A. Heap
- B. Queue
- C. Stack
- D. Linked list
Show answerHide answer
Answer: C. Stack
The last item pushed onto a stack is the first one popped.Q2. Which data structure follows First In, First Out (FIFO)?
- A. Tree
- B. Graph
- C. Stack
- D. Queue
Show answerHide answer
Answer: D. Queue
A queue serves items in the order they arrive.Q3. What is the time complexity of binary search on a sorted array?
- A. O(log n)
- B. O(n log n)
- C. O(1)
- D. O(n)
Show answerHide answer
Answer: A. O(log n)
Each step halves the search range.Q4. What is the worst-case time complexity of quicksort?
- A. O(log n)
- B. O(n)
- C. O(n²)
- D. O(n log n)
Show answerHide answer
Answer: C. O(n²)
With bad pivots (e.g. already sorted input and first-element pivot) it degrades to O(n²). Average is O(n log n).Q5. Which sorting algorithm is guaranteed O(n log n) in the worst case?
- A. Insertion sort
- B. Quick sort
- C. Merge sort
- D. Bubble sort
Show answerHide answer
Answer: C. Merge sort
Merge sort always splits in half and merges in linear time.Q6. Which traversal of a binary search tree gives the values in sorted order?
- A. In-order
- B. Post-order
- C. Pre-order
- D. Level-order
Show answerHide answer
Answer: A. In-order
In-order visits left subtree, node, right subtree.Q7. What is the average time to look up a key in a hash table?
- A. O(1)
- B. O(n²)
- C. O(log n)
- D. O(n)
Show answerHide answer
Answer: A. O(1)
Hashing jumps straight to the bucket; collisions make the worst case O(n).Q8. Which algorithm finds the shortest path in a graph with non-negative edge weights?
- A. Dijkstra's algorithm
- B. Kruskal's algorithm
- C. Bubble sort
- D. Depth-first search
Show answerHide answer
Answer: A. Dijkstra's algorithm
Dijkstra greedily expands the closest unvisited vertex. Kruskal finds a minimum spanning tree, not shortest paths.Q9. Breadth-first search (BFS) typically uses which data structure?
- A. Stack
- B. Heap
- C. Hash set only
- D. Queue
Show answerHide answer
Answer: D. Queue
BFS explores level by level, processing vertices in the order they were discovered.Q10. Depth-first search (DFS) can be implemented with recursion or which data structure?
- A. Array of size 1
- B. Queue
- C. Stack
- D. Priority queue
Show answerHide answer
Answer: C. Stack
Recursion uses the call stack; an explicit stack works the same way.Q11. What is the maximum number of nodes in a binary tree of height h (root at height 0)?
- A. 2^h
- B. 2^(h+1) − 1
- C. h²
- D. 2h + 1
Show answerHide answer
Answer: B. 2^(h+1) − 1
Each level doubles: 1 + 2 + 4 + … + 2^h = 2^(h+1) − 1.Q12. Inserting at the beginning of a singly linked list takes:
- A. O(n)
- B. O(log n)
- C. O(1)
- D. O(n²)
Show answerHide answer
Answer: C. O(1)
Just point the new node at the old head.Q13. Accessing the i-th element of an array takes:
- A. O(i²)
- B. O(log n)
- C. O(n)
- D. O(1)
Show answerHide answer
Answer: D. O(1)
Arrays use contiguous memory, so the address is computed directly.Q14. Which data structure is best for implementing a priority queue?
- A. Linked list
- B. Stack
- C. Heap
- D. Array sorted after every insert
Show answerHide answer
Answer: C. Heap
A binary heap gives O(log n) insert and extract-min/max.Q15. What does dynamic programming rely on?
- A. Random choices
- B. Greedy choices only
- C. Sorting the input first
- D. Overlapping subproblems and optimal substructure
Show answerHide answer
Answer: D. Overlapping subproblems and optimal substructure
DP stores answers to repeated subproblems instead of recomputing them.Q16. Which technique is used in the 'two-sum on a sorted array' O(n) solution?
- A. Bit manipulation
- B. Backtracking
- C. Divide and conquer
- D. Two pointers
Show answerHide answer
Answer: D. Two pointers
Move the left pointer up when the sum is too small and the right pointer down when too big.Q17. What is the space complexity of merge sort on an array?
- A. O(n)
- B. O(log n)
- C. O(1)
- D. O(n²)
Show answerHide answer
Answer: A. O(n)
Merging needs a temporary array of size n.Q18. A graph with V vertices stored as an adjacency matrix needs how much space?
- A. O(V²)
- B. O(V + E)
- C. O(V)
- D. O(E)
Show answerHide answer
Answer: A. O(V²)
A V × V matrix. Adjacency lists need O(V + E).Q19. Which problem is typically solved with backtracking?
- A. Computing an average
- B. Binary search
- C. N-Queens
- D. Finding the maximum of an array
Show answerHide answer
Answer: C. N-Queens
Backtracking tries choices and undoes them when they lead to a dead end.Q20. Detecting a cycle in a linked list in O(1) extra space uses:
- A. A hash set
- B. Sorting
- C. Floyd's slow and fast pointers
- D. Recursion
Show answerHide answer
Answer: C. Floyd's slow and fast pointers
If there's a cycle, the fast pointer eventually meets the slow one. A hash set works but uses O(n) space.Q21. What is the time complexity of building a heap from n elements (heapify)?
- A. O(n log n)
- B. O(log n)
- C. O(n²)
- D. O(n)
Show answerHide answer
Answer: D. O(n)
Bottom-up heapify is O(n) because most nodes are near the leaves.Q22. Which of these is a stable sorting algorithm?
- A. Quick sort (typical)
- B. Merge sort
- C. Selection sort
- D. Heap sort
Show answerHide answer
Answer: B. Merge sort
Stable sorts keep equal elements in their original order.Q23. A balanced binary search tree (like AVL) guarantees search in:
- A. O(n)
- B. O(log n)
- C. O(n log n)
- D. O(1)
Show answerHide answer
Answer: B. O(log n)
Balancing keeps the height about log n.Q24. Which data structure is used to check balanced parentheses?
- A. Graph
- B. Stack
- C. Queue
- D. Heap
Show answerHide answer
Answer: B. Stack
Push openers, pop and compare on closers.Q25. Kadane's algorithm solves which problem?
- A. Shortest path
- B. Sorting
- C. Maximum subarray sum
- D. Minimum spanning tree
Show answerHide answer
Answer: C. Maximum subarray sum
It tracks the best sum ending at each position in O(n).Q26. What is a 'trie' mainly used for?
- A. Shortest paths
- B. Prefix searches on strings
- C. Sorting numbers
- D. Matrix multiplication
Show answerHide answer
Answer: B. Prefix searches on strings
Tries store strings character by character, making prefix lookups fast (autocomplete).Q27. Topological sort applies to which kind of graph?
- A. Graphs with cycles
- B. Complete graphs only
- C. Any undirected graph
- D. Directed acyclic graph (DAG)
Show answerHide answer
Answer: D. Directed acyclic graph (DAG)
It orders tasks so every dependency comes before the task that needs it.Q28. Which algorithm builds a minimum spanning tree?
- A. Dijkstra's algorithm
- B. Kruskal's algorithm
- C. KMP
- D. Binary search
Show answerHide answer
Answer: B. Kruskal's algorithm
Kruskal (and Prim) find the cheapest set of edges connecting all vertices.Q29. The 'sliding window' technique is most useful for:
- A. Graph colouring
- B. Tree traversal
- C. Problems on contiguous subarrays or substrings
- D. Sorting linked lists
Show answerHide answer
Answer: C. Problems on contiguous subarrays or substrings
Expand and shrink a window instead of re-checking every subarray.Q30. What is the time complexity of inserting into a Python list at index 0?
- A. O(log n)
- B. O(n)
- C. O(1)
- D. O(n²)
Show answerHide answer
Answer: B. O(n)
Every existing element shifts right. Use collections.deque for O(1) appends on both ends.Q31. Memoization means:
- A. Sorting results
- B. Writing code comments
- C. Caching function results for inputs already computed
- D. Using less memory
Show answerHide answer
Answer: C. Caching function results for inputs already computed
It turns exponential recursion like naive Fibonacci into linear time.Q32. In a min-heap, the smallest element is always:
- A. Anywhere
- B. At the last leaf
- C. At the root
- D. In the middle
Show answerHide answer
Answer: C. At the root
Every parent is ≤ its children, so the minimum sits at the top.Q33. How many edges does a tree with n nodes have?
- A. 2n
- B. n − 1
- C. n + 1
- D. n
Show answerHide answer
Answer: B. n − 1
A tree is connected with no cycles, which needs exactly n − 1 edges.Q34. Which search works on unsorted data?
- A. Linear search
- B. Exponential search
- C. Binary search
- D. Interpolation search
Show answerHide answer
Answer: A. Linear search
Without order, you have to check elements one by one.Q35. A recursive function without a base case will cause:
- A. Faster execution
- B. A syntax error
- C. Stack overflow (RecursionError in Python)
- D. It to return None
Show answerHide answer
Answer: C. Stack overflow (RecursionError in Python)
Each call adds a stack frame until memory runs out.Q36. Which data structure follows Last In, First Out (LIFO)?
- A. Heap
- B. Queue
- C. Stack
- D. Linked list
Show answerHide answer
Answer: C. Stack
The last item pushed is the first one popped.Q37. Which data structure follows First In, First Out (FIFO)?
- A. Queue
- B. Binary search tree
- C. Hash table
- D. Stack
Show answerHide answer
Answer: A. Queue
Items leave in the order they arrived, like a ticket counter line.Q38. Which data structure is best for checking balanced brackets?
- A. Stack
- B. Graph
- C. Queue
- D. Array
Show answerHide answer
Answer: A. Stack
Push opening brackets and pop on closing ones.Q39. What is a circular queue used for?
- A. Reusing empty slots at the front of a fixed array
- B. Storing a tree
- C. Sorting elements
- D. Searching faster
Show answerHide answer
Answer: A. Reusing empty slots at the front of a fixed array
The rear wraps around to index 0 when space is free.Q40. In a singly linked list, what does each node store?
- A. Data and a pointer to the next node
- B. An index into an array
- C. Data only
- D. Pointers to the next and previous nodes
Show answerHide answer
Answer: A. Data and a pointer to the next node
A doubly linked list also stores a pointer to the previous node.Q41. What is the main advantage of a linked list over an array?
- A. Fast insertion and deletion without shifting elements
- B. Fast random access by index
- C. Better cache performance
- D. Less memory per element
Show answerHide answer
Answer: A. Fast insertion and deletion without shifting elements
Arrays give O(1) indexing; linked lists give O(1) insert/delete once you have the node.Q42. Which technique detects a cycle in a linked list using O(1) extra space?
- A. Sorting the list
- B. Hashing every node
- C. Floyd's slow and fast pointers
- D. Binary search
Show answerHide answer
Answer: C. Floyd's slow and fast pointers
If the fast pointer ever meets the slow one, there is a cycle.Q43. How do you find the middle of a linked list in one pass?
- A. Count nodes twice
- B. Move one pointer by 1 and another by 2; when the fast one ends, the slow one is in the middle
- C. Reverse the list first
- D. Use binary search
Show answerHide answer
Answer: B. Move one pointer by 1 and another by 2; when the fast one ends, the slow one is in the middle
The slow/fast pointer technique.Q44. In a binary search tree, where are values smaller than the root stored?
- A. In the right subtree
- B. In the left subtree
- C. Anywhere
- D. In the root only
Show answerHide answer
Answer: B. In the left subtree
Left subtree < node < right subtree.Q45. Which traversal of a binary search tree gives the values in sorted order?
- A. Inorder
- B. Postorder
- C. Level order
- D. Preorder
Show answerHide answer
Answer: A. Inorder
Inorder visits left, node, right.Q46. Which traversal visits a tree level by level?
- A. Postorder
- B. Preorder
- C. Inorder
- D. Breadth-first (level order)
Show answerHide answer
Answer: D. Breadth-first (level order)
It uses a queue.Q47. What is the maximum number of nodes in a binary tree of height h (root at height 1)?
- A. h²
- B. 2^h − 1
- C. 2h
- D. 2^(h+1)
Show answerHide answer
Answer: B. 2^h − 1
A full tree has 1 + 2 + 4 + … + 2^(h−1) nodes.Q48. What is the height of a balanced binary tree with n nodes?
- A. About log₂ n
- B. About √n
- C. About n/2
- D. About n
Show answerHide answer
Answer: A. About log₂ n
Each level doubles the number of nodes.Q49. What happens to BST search time if the tree becomes a straight line (skewed)?
- A. It stays O(log n)
- B. It becomes O(1)
- C. It becomes O(n)
- D. It becomes O(n²)
Show answerHide answer
Answer: C. It becomes O(n)
Self-balancing trees like AVL and red-black trees prevent this.Q50. Which property does every node satisfy in a max-heap?
- A. Left child < parent < right child
- B. Each parent is greater than or equal to its children
- C. All leaves are at the same level
- D. Children are sorted
Show answerHide answer
Answer: B. Each parent is greater than or equal to its children
So the maximum is always at the root.Q51. What is the time to insert into a binary heap of n elements?
- A. O(n log n)
- B. O(log n)
- C. O(1)
- D. O(n)
Show answerHide answer
Answer: B. O(log n)
The new element sifts up at most the height of the heap.Q52. Which data structure is used to implement a priority queue efficiently?
- A. Hash table
- B. Linked list
- C. Heap
- D. Stack
Show answerHide answer
Answer: C. Heap
Heaps give O(log n) insert and remove-top.Q53. What is a hash collision?
- A. A key that can't be hashed
- B. Two keys mapping to the same bucket
- C. Deleting a key twice
- D. A full hash table
Show answerHide answer
Answer: B. Two keys mapping to the same bucket
Handled with chaining (lists in buckets) or open addressing (probing).Q54. Which collision-handling method stores colliding keys in a list per bucket?
- A. Linear probing
- B. Double hashing
- C. Separate chaining
- D. Rehashing
Show answerHide answer
Answer: C. Separate chaining
Probing methods look for another empty slot instead.Q55. What is the load factor of a hash table?
- A. Time to compute a hash
- B. Number of entries divided by number of buckets
- C. Number of collisions
- D. Size of the largest bucket
Show answerHide answer
Answer: B. Number of entries divided by number of buckets
When it gets too high, tables resize (rehash) to stay fast.Q56. Which graph traversal uses a queue?
- A. Inorder traversal
- B. Dijkstra's with a stack
- C. Breadth-first search (BFS)
- D. Depth-first search (DFS)
Show answerHide answer
Answer: C. Breadth-first search (BFS)
BFS explores neighbours level by level.Q57. Which graph traversal is naturally written with recursion or a stack?
- A. Depth-first search (DFS)
- B. Level-order traversal
- C. Breadth-first search (BFS)
- D. Kruskal's algorithm
Show answerHide answer
Answer: A. Depth-first search (DFS)
DFS goes as deep as possible before backtracking.Q58. Which algorithm finds the shortest path in an unweighted graph?
- A. Topological sort
- B. Prim's algorithm
- C. DFS
- D. BFS
Show answerHide answer
Answer: D. BFS
BFS reaches nodes in order of distance (number of edges).Q59. Which algorithm finds shortest paths from one source when edge weights are non-negative?
- A. DFS
- B. Kruskal's algorithm
- C. Bubble sort
- D. Dijkstra's algorithm
Show answerHide answer
Answer: D. Dijkstra's algorithm
Bellman-Ford handles negative weights.Q60. Which algorithm can handle negative edge weights and detect negative cycles?
- A. Prim
- B. Bellman-Ford
- C. Dijkstra
- D. BFS
Show answerHide answer
Answer: B. Bellman-Ford
It relaxes all edges V − 1 times.Q61. What does a minimum spanning tree connect?
- A. All vertices with the smallest total edge weight and no cycles
- B. Vertices in sorted order
- C. Every pair of vertices directly
- D. Only the two farthest vertices
Show answerHide answer
Answer: A. All vertices with the smallest total edge weight and no cycles
Prim's and Kruskal's algorithms build MSTs.Q62. Kruskal's algorithm picks edges in which order?
- A. Random order
- B. Increasing order of weight
- C. Order of vertex numbers
- D. Decreasing order of weight
Show answerHide answer
Answer: B. Increasing order of weight
It skips edges that would form a cycle (using union-find).Q63. Topological sort is possible only for which graphs?
- A. Directed acyclic graphs (DAGs)
- B. Undirected graphs
- C. Graphs with cycles
- D. Complete graphs
Show answerHide answer
Answer: A. Directed acyclic graphs (DAGs)
Used for task scheduling and course prerequisites.Q64. How is a graph with V vertices stored in an adjacency matrix?
- A. A V × V table where cell [i][j] marks an edge
- B. A list of V linked lists
- C. A binary tree
- D. A single array of edges
Show answerHide answer
Answer: A. A V × V table where cell [i][j] marks an edge
Matrices use O(V²) space; adjacency lists use O(V + E).Q65. Which is better for a sparse graph with few edges?
- A. Adjacency list
- B. Adjacency matrix
- C. Neither can store it
- D. Both use the same memory
Show answerHide answer
Answer: A. Adjacency list
Lists only store the edges that exist.Q66. Which sorting algorithm is stable and always O(n log n)?
- A. Selection sort
- B. Heap sort
- C. Merge sort
- D. Quick sort
Show answerHide answer
Answer: C. Merge sort
Merge sort keeps equal elements in their original order.Q67. What is the worst-case time of quick sort?
- A. O(n log n)
- B. O(n)
- C. O(log n)
- D. O(n²)
Show answerHide answer
Answer: D. O(n²)
It happens with bad pivots, e.g. an already sorted array with the first element as pivot.Q68. Which sorting algorithm works best on an almost-sorted array?
- A. Quick sort with the first element as pivot
- B. Heap sort
- C. Insertion sort
- D. Selection sort
Show answerHide answer
Answer: C. Insertion sort
Insertion sort is close to O(n) when few elements are out of place.Q69. Which sort repeatedly selects the minimum element and swaps it to the front?
- A. Bubble sort
- B. Selection sort
- C. Merge sort
- D. Insertion sort
Show answerHide answer
Answer: B. Selection sort
It does at most n − 1 swaps.Q70. Counting sort is efficient when:
- A. The values are strings
- B. The values are integers in a small range
- C. The array is huge with any values
- D. Memory is very limited
Show answerHide answer
Answer: B. The values are integers in a small range
It runs in O(n + k) where k is the range of values.Q71. What does 'in-place' sorting mean?
- A. It never swaps elements
- B. It uses only O(1) or very little extra memory
- C. It sorts in O(1) time
- D. It keeps equal elements in order
Show answerHide answer
Answer: B. It uses only O(1) or very little extra memory
Quick sort and heap sort are in-place; merge sort needs O(n) extra space.Q72. Binary search requires the array to be:
- A. Stored in a linked list
- B. Of even length
- C. Without negative numbers
- D. Sorted
Show answerHide answer
Answer: D. Sorted
It decides which half to discard by comparing with the middle element.Q73. What is dynamic programming?
- A. Solving problems with random choices
- B. Writing programs that change at run time
- C. Solving overlapping subproblems once and reusing their answers
- D. Allocating memory dynamically
Show answerHide answer
Answer: C. Solving overlapping subproblems once and reusing their answers
Memoization (top-down) or tabulation (bottom-up).Q74. Which problem is a classic example of dynamic programming?
- A. Linear search
- B. Reversing a string
- C. 0/1 knapsack
- D. Binary search
Show answerHide answer
Answer: C. 0/1 knapsack
Each item is either taken or not, and subproblems overlap.Q75. What is a greedy algorithm?
- A. One that makes the best local choice at each step
- B. One that always uses recursion
- C. One that tries every possibility
- D. One that sorts first
Show answerHide answer
Answer: A. One that makes the best local choice at each step
Works when local choices lead to a global optimum, as in activity selection.Q76. Which problem is solved correctly by a greedy approach?
- A. Travelling salesman
- B. 0/1 knapsack
- C. Longest common subsequence
- D. Activity selection (maximum non-overlapping intervals)
Show answerHide answer
Answer: D. Activity selection (maximum non-overlapping intervals)
Pick the activity that finishes earliest, repeatedly.Q77. What is backtracking?
- A. Trying a choice, and undoing it when it leads to a dead end
- B. Sorting in reverse
- C. Traversing a list from the tail
- D. Running a loop backwards
Show answerHide answer
Answer: A. Trying a choice, and undoing it when it leads to a dead end
Used for N-Queens, Sudoku and generating permutations.Q78. What does the sliding window technique help with?
- A. Problems on contiguous subarrays or substrings
- B. Sorting linked lists
- C. Tree traversal
- D. Graph colouring
Show answerHide answer
Answer: A. Problems on contiguous subarrays or substrings
Move the window's ends instead of recomputing from scratch.Q79. Which technique solves 'pair with given sum' in a sorted array in O(n)?
- A. Recursion
- B. Nested loops
- C. Binary search for every pair
- D. Two pointers from both ends
Show answerHide answer
Answer: D. Two pointers from both ends
Move the left pointer up if the sum is small, the right one down if it is big.Q80. What does Kadane's algorithm find?
- A. The median
- B. The longest increasing subsequence
- C. The maximum sum of a contiguous subarray
- D. The shortest path
Show answerHide answer
Answer: C. The maximum sum of a contiguous subarray
Keep the best sum ending here and the best overall.Q81. Which data structure supports finding the minimum in O(1) along with push and pop?
- A. A plain queue
- B. A stack that also keeps a stack of minimums
- C. A sorted array
- D. A hash set
Show answerHide answer
Answer: B. A stack that also keeps a stack of minimums
The 'min stack' interview question.Q82. What is a trie used for?
- A. Finding shortest paths
- B. Balancing trees
- C. Sorting numbers
- D. Storing strings for fast prefix search
Show answerHide answer
Answer: D. Storing strings for fast prefix search
Autocomplete and dictionaries use tries.Q83. What is the union-find (disjoint set) data structure used for?
- A. Tracking which elements belong to the same group
- B. Sorting strings
- C. Finding the maximum
- D. Reversing a list
Show answerHide answer
Answer: A. Tracking which elements belong to the same group
With path compression it is nearly O(1) per operation; Kruskal's uses it.Q84. Which data structure is used for an LRU cache?
- A. Hash map + doubly linked list
- B. Stack only
- C. Binary search tree only
- D. Array only
Show answerHide answer
Answer: A. Hash map + doubly linked list
The map finds entries in O(1); the list keeps them in order of use.Q85. What is a deque?
- A. A sorted queue
- B. A queue with only one end
- C. A queue of queues
- D. A double-ended queue that allows insert and remove at both ends
Show answerHide answer
Answer: D. A double-ended queue that allows insert and remove at both ends
Used in the sliding-window maximum problem.Q86. How many edges does a tree with n vertices have?
- A. n + 1
- B. n
- C. 2n
- D. n − 1
Show answerHide answer
Answer: D. n − 1
Every vertex except the root has exactly one parent edge.Q87. Which data structure is the natural choice for an 'undo' feature in a text editor?
- A. Stack
- B. Hash table
- C. Queue
- D. Binary search tree
Show answerHide answer
Answer: A. Stack
Each action is pushed; undo pops the most recent one.Q88. Which algorithm finds strongly connected components in a directed graph?
- A. Dijkstra's algorithm
- B. Kosaraju's or Tarjan's algorithm
- C. Prim's algorithm
- D. Binary search
Show answerHide answer
Answer: B. Kosaraju's or Tarjan's algorithm
Both run in O(V + E).Q89. What is memoization?
- A. Storing variables in registers
- B. Writing memos in code comments
- C. Allocating memory for arrays
- D. Caching results of function calls to avoid recomputation
Show answerHide answer
Answer: D. Caching results of function calls to avoid recomputation
Turns exponential Fibonacci into linear time.Q90. What is a self-balancing BST?
- A. A tree with only one child per node
- B. A BST that keeps its height O(log n) after inserts and deletes
- C. A BST stored in an array
- D. A BST with equal values on both sides
Show answerHide answer
Answer: B. A BST that keeps its height O(log n) after inserts and deletes
Examples: AVL trees and red-black trees.Q91. Which data structure would you use to check if a word exists among a million words fastest on average?
- A. Linked list
- B. Unsorted array
- C. Stack
- D. Hash set
Show answerHide answer
Answer: D. Hash set
Average O(1) lookup.Q92. Which problem asks for the length of the longest subsequence common to two strings?
- A. Longest palindromic substring
- B. Longest common subsequence (LCS)
- C. Knapsack
- D. Edit distance
Show answerHide answer
Answer: B. Longest common subsequence (LCS)
A classic 2D dynamic-programming problem.Q93. What does the edit distance between two strings measure?
- A. The difference in their lengths
- B. Their alphabetical order
- C. The number of common letters
- D. The minimum inserts, deletes and replacements to turn one into the other
Show answerHide answer
Answer: D. The minimum inserts, deletes and replacements to turn one into the other
Also called Levenshtein distance; solved with dynamic programming.Q94. What is the time to access the k-th element of a linked list?
- A. O(log k)
- B. O(k²)
- C. O(k)
- D. O(1)
Show answerHide answer
Answer: C. O(k)
You must walk from the head.Q95. Which data structure is used for function calls in a program?
- A. A heap
- B. The call stack
- C. A queue
- D. A hash table
Show answerHide answer
Answer: B. The call stack
Each call pushes a frame; returning pops it. Too deep recursion overflows it.
Practised these? Now prove it.
Take a timed mock test with new questions every attempt, earn a verified certificate at 70%+, and get noticed by employers.
Start a mock test