Recall & Review
beginner
What is the main idea behind searching in a 2D matrix where each row and column is sorted?
Start from the top-right corner and move left if the current element is greater than the target, or move down if it is smaller. This way, you eliminate a row or a column in each step.
Click to reveal answer
beginner
Why is starting from the top-right corner effective in searching a sorted 2D matrix?
Because from the top-right corner, moving left decreases the value and moving down increases the value, helping to decide the direction to find the target efficiently.
Click to reveal answer
intermediate
What is the time complexity of searching in a sorted 2D matrix using the top-right corner approach?
O(m + n), where m is the number of rows and n is the number of columns, because each step moves either one row down or one column left.
Click to reveal answer
beginner
In a 2D matrix sorted row-wise and column-wise, what happens if the target is smaller than the current element at top-right?
You move left to the previous column because all elements below are larger, so the target cannot be in the current column.
Click to reveal answer
intermediate
What is a simple alternative approach to search in a 2D matrix if it is treated as a sorted 1D array?
Use binary search by mapping 2D indices to 1D indices, since the matrix is sorted row-wise and column-wise, treating it as a single sorted list.
Click to reveal answer
Where do you start searching in a sorted 2D matrix to efficiently find a target?
✗ Incorrect
Starting at the top-right corner allows moving left or down to eliminate rows or columns efficiently.
If the current element is greater than the target, what is the next move in the top-right corner search?
✗ Incorrect
Moving left decreases the element value, helping to find smaller target values.
What is the time complexity of the top-right corner search in a matrix with m rows and n columns?
✗ Incorrect
Each step moves either one row down or one column left, so total steps are at most m + n.
Which of these is NOT true about the 2D matrix search starting at top-right?
✗ Incorrect
You never move right in this approach; moving right would increase the element value.
What alternative method can be used if the matrix is sorted and treated as a 1D array?
✗ Incorrect
Binary search can be applied by mapping 2D indices to 1D indices in a sorted matrix.
Explain the step-by-step process of searching for a target in a 2D matrix sorted by rows and columns using the top-right corner approach.
Think about how moving left or down helps eliminate parts of the matrix.
You got /5 concepts.
Describe how binary search can be applied to a 2D matrix sorted row-wise and column-wise by treating it as a 1D array.
Think about flattening the matrix conceptually without changing the data.
You got /5 concepts.