0
0
DSA C++programming~5 mins

Floor and Ceil in Sorted Array in DSA C++ - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
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.
Click to reveal answer
beginner
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.
Click to reveal answer
intermediate
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.
Click to reveal answer
intermediate
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.
Click to reveal answer
intermediate
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).
Click to reveal answer
What does the floor of a number represent in a sorted array?
AGreatest element greater than the number
BSmallest element greater than the number
CSmallest element less than the number
DGreatest element less than or equal to the number
What is the ceil of 7 in the sorted array [1, 3, 5, 8, 10]?
A8
B5
C7
D10
Which algorithm is best to find floor and ceil in a sorted array efficiently?
ALinear search
BBinary search
CBubble sort
DDepth-first search
If the target is smaller than all elements, what is the floor?
ADoes not exist
BLargest element
CTarget itself
DSmallest element
If the target is larger than all elements, what is the ceil?
ASmallest element
BLargest element
CDoes not exist
DTarget itself
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 where the number fits.
You got /4 concepts.
    Describe edge cases when finding floor and ceil in a sorted array.
    Consider what happens when the target is outside the array range.
    You got /4 concepts.