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 is the time complexity of binary search on a sorted array of n elements?
Answer: O(log n)
Binary search halves the search space each step, giving O(log n) complexity.
Which data structure operates on a Last-In-First-Out (LIFO) principle?
Answer: Stack
A stack uses LIFO: the last element pushed is the first one popped.
A recursive function calls itself with n-1 until n=0. If n starts at 5, how many total calls are made?
Answer: 6
Calls: f(5)→f(4)→f(3)→f(2)→f(1)→f(0). That is 6 total calls including the base case.
Which sorting algorithm has the best average-case time complexity?
Answer: Quicksort
Quicksort has O(n log n) average-case complexity, better than the O(n²) of bubble, selection, and insertion sort.
In pseudocode: x=10; WHILE x>0: x=x-3; PRINT x; — how many times is PRINT executed?
Answer: 4
x: 10→7→4→1→-2. PRINT fires when x=7, x=4, x=1, x=-2 (after loop exits? No — print is inside loop). x goes 10→7(print)→4(print)→1(print)→-2: loop ends as x=-2 which is not >0 but the print happens after x=x-3. So prints: x=7,4,1,-2 = 4 times.
What is the output of: x=2; y=3; z=x**y + y**x; PRINT z?
Answer: 13
x**y = 2³=8, y**x = 3²=9. z = 8+9 = 17. Wait — 8+9=17, so the answer is 17.