Algorithmic Problem Solving Questions and Answers Flashcards
6 cards from real Epic Skills Assessment practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 6 Algorithmic Problem Solving Questions and Answers flashcards as text
What does a hash table provide for average-case lookup operations?
Answer: O(1)
Hash tables provide O(1) average-case lookup by computing the index directly from the key via a hash function.
An algorithm doubles its run time for every additional input element. What is its time complexity?
Answer: O(2ⁿ)
If run time doubles with each additional element, the complexity is exponential: O(2ⁿ).
Which of the following is an example of a greedy algorithm?
Answer: Dijkstra's Shortest Path
Dijkstra's algorithm is greedy — it always picks the unvisited node with the smallest known distance, making a locally optimal choice at each step.
What is the space complexity of an iterative (non-recursive) Fibonacci function?
Answer: O(1)
An iterative Fibonacci function only stores a constant number of variables (the last two values), so space complexity is O(1).
Given a sorted list [1,3,5,7,9,11], what is the maximum number of comparisons binary search needs to find 11?
Answer: 3
n=6, log₂(6)≈2.58, so at most 3 comparisons (ceiling). Steps: mid=5(index 2), 11>5 → right half [7,9,11]; mid=9(index 4), 11>9 → right [11]; mid=11, found. That's 3 comparisons.
In a depth-first search (DFS) of a graph, which data structure is implicitly used?
Answer: Stack
DFS uses a stack (either explicitly or via the call stack in recursive implementations) to track the path and backtrack when needed.