Search in row and col wise sorted matrix

how to decide that random value in the matrix referred as index ‘v’ in the video.

moreover there is no further video on its implementation.

please resolve the issues.


that is not a random v
bhaiya has taken it done a binary search over the matrix and choosen the v strategically

from the code u can figure out how the v cell is getting selected

if the target is less than present element then move a col behinde ( col–)
else if target is greater then row++
else return true ( when element == target)

From where will ‘v’ start… Can I start it from top left i.e.(0,0) index of the array.??

https://ide.codingblocks.com/s/260075 The line of doubt is commented, please explain!

no u cannot start from 0 , col-1

for a n*m matrix
see
we start the search from the 0th row and last column
and we move down if we target is greater hence we have the possibility that we reach the n-1 th row ( last row)
or we move left in case the target is less than present element ( we move leftwards)
so

while (s < r and e >= 0)
this line keeps out search bounded inside the matrix
and not go beyond the matrix left and bottom boundaries

image

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.