Arrays Quiz
Editorial
13 questions across the four Arrays lessons: what an operation costs, what a pass carries, what each rearrangement does, and why cyclic sort and the vote work. Pick an answer to see whether it's right and why. Nothing is saved, so you can take it again.
If one trips you up, its lesson is Introduction to Arrays, Rearranging Arrays in Place, Cyclic Sort or Majority Element and Boyer–Moore Voting.
Quiz
1 / 13Multiple choice
An array holds a million values. Which of these is O(1)?
Multiple choice
Which growth rule would make a dynamic array's appends cost O(n) each on average?
Multiple choice
Best Time to Buy and Sell Stock in one pass. What do you carry from day to day?
Multiple choice
Second largest in one pass: the new value x beats first. What happens?
Multiple choice
find_max starts with best = 0. What does it return for [-3, -7, -1]?
Multiple choice
Rotate right by k with three reversals. Which order?
Multiple choice
[3, 4, 5, 1, 2]: going round the circle, how many drops are there, and was it a sorted array rotated?
Multiple choice
What is the next permutation of [1, 2, 3, 2]?
Multiple choice
After cyclic sort, [3, 1, 2, 2, 5] became [1, 2, 3, 2, 5]. What's missing, and what's repeated?
Multiple choice
First Missing Positive on [7, 8, 9]?
Multiple choice
Boyer–Moore on [1, 1, 2, 2, 2]. What are the candidate and the count after the fourth value?
Multiple choice
Boyer–Moore on [1, 2, 3, 4, 5] ends with candidate 5 and count 1. What's the majority?
Multiple choice
Majority Element II: why check x against both candidates before taking an empty count?