Recall & Review
beginner Click to reveal answer
What is the floor of a number in a sorted array?
The floor of a number is the greatest element in the array that is less than or equal to that number.
beginner Click to reveal answer
What is the ceil of a number in a sorted array?
The ceil of a number is the smallest element in the array that is greater than or equal to that number.
intermediate Click to reveal answer
Why is binary search useful for finding floor and ceil in a sorted array?
Binary search helps find floor and ceil efficiently by repeatedly dividing the search space in half, reducing time from linear to logarithmic.
intermediate Click to reveal answer
If the target number is smaller than all elements in the array, what is the floor and ceil?
Floor does not exist (no element ≤ target), ceil is the smallest element in the array.
intermediate Click to reveal answer
If the target number is larger than all elements in the array, what is the floor and ceil?
Floor is the largest element in the array, ceil does not exist (no element ≥ target).
What does the floor of a number represent in a sorted array?
✗ Incorrect
Floor is the greatest element less than or equal to the target number.
What is the time complexity of finding floor or ceil using binary search in a sorted array of size n?
✗ Incorrect
Binary search divides the search space in half each step, so it runs in O(log n) time.
If the target number is exactly equal to an element in the array, what are floor and ceil?
✗ Incorrect
When target matches an element, floor and ceil are that element itself.
If the target number is smaller than all elements in the array, what is the floor?
✗ Incorrect
No element is less than or equal to target, so floor does not exist.
Which approach is best to find floor and ceil in a sorted array?
✗ Incorrect
Binary search efficiently finds floor and ceil in O(log n) time.
Explain how to find the floor and ceil of a number in a sorted array using binary search.
Think about how binary search narrows down the search space and updates floor or ceil candidates.
You got /4 concepts.
Describe what happens when the target number is outside the range of the sorted array elements for floor and ceil.
Consider the array boundaries and what floor and ceil mean.
You got /3 concepts.
