INTERVIEW QUESTIONS
ALGORITHM
DETAILS
Question: How do you apply Binary Search on 2D array supposed you have 2D array with integers sorted both horizontally and vertically. If you find any occurrence of the value you are looking for you return true else false. What is the complexity?
For example the 2D array could look like the following
1 4 5 6 2 5 7 9
Answer: search diagonally.
diag 1 = 1 diag2 = 2,4 ….
for example given the number 7 we take the bounds of each diagonal and check wether the number will fall in that range else move farward. here diagonal selection is sequential but the number search is binary.
|