0
0
DSA Typescriptprogramming~5 mins

Search in 2D Matrix in DSA Typescript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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 number is greater than the target, or move down if it is smaller. This way, you eliminate a row or a column each step.
Click to reveal answer
beginner
Why is starting from the top-right corner effective in a sorted 2D matrix search?
Because from the top-right corner, moving left decreases the value and moving down increases the value, helping to decide the direction to move based on comparison with the target.
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 the context of searching a 2D matrix, what does it mean if the current element is less than the target?
It means you should move down to the next row because all elements to the left are smaller and won't match the target.
Click to reveal answer
beginner
What happens if the target is not found after moving through the matrix using the top-right corner approach?
You conclude the target is not in the matrix because you have eliminated all possible positions by moving left or down.
Click to reveal answer
Where do you start searching in a sorted 2D matrix to efficiently find a target?
ABottom-left corner
BTop-right corner
CTop-left corner
DBottom-right corner
If the current element is greater than the target, what is the next move?
AMove left
BMove down
CMove right
DMove up
What is the time complexity of the search algorithm in a sorted 2D matrix?
AO(m + n)
BO(log(m * n))
CO(1)
DO(m * n)
If the current element is less than the target, where should you move next?
ALeft
BUp
CRight
DDown
What does it mean if you reach outside the matrix boundaries without finding the target?
ATarget is found
BMatrix is empty
CTarget is not in the matrix
DMatrix is unsorted
Explain the step-by-step process to search for a target in a sorted 2D matrix.
Think about how to eliminate rows or columns based on comparison.
You got /5 concepts.
    Describe why the search in a sorted 2D matrix is efficient compared to checking every element.
    Focus on how sorting helps reduce search space.
    You got /4 concepts.