It feels like this method is suboptimal, because, for example, if the matrix is 1 x n or n x 1 then we could do a binary search instead of linear search.
@prateekrai6653 жыл бұрын
Awesome explanation. :)
@mitakshichandna1723 жыл бұрын
why didnt we use else if instead of second if statement?:(
@ankitsharma82215 жыл бұрын
Awesome explanation!
@jeevanadhikari15887 жыл бұрын
Can you please show the derivation of time complexity for this algorithm to O(n)
@rajvijay32766 жыл бұрын
In the worst case , starting from the top right corner , element will be found at bottom left corner. No. of comparisons you do is going to be n. Hence O(n).
@ravindraPratapsingh76 жыл бұрын
In the worst case if 32 (in given matrix) need to be searched (left most, down most element). The number of comparisons will be : n (row traversal) + n (column traversal) = 2n , So Time complexity can be stated as O(n).
@pranavamjks5 жыл бұрын
As mentioned by others, complexity here stands for the number of comparisons the algorithm make. Either one row or column gets deleted at each step. So either row count or column count gets decreased by one at each step. This essentially means that we will have, at the maximum, n+m number of steps, which is essentially the number of comparisons.
@ksuman-in7 жыл бұрын
when finding the first column of the value then not find the accurate value for example I'm finding 15 then not found.
@SaurabhKumar-th3gm7 жыл бұрын
Can We start from bottom left most element.
@amarbathwal12267 жыл бұрын
Saurabh Kumar yes u can
@harishkulkarni72447 жыл бұрын
Yes but the algorithm would change, if e < x then you would move towards right since the elements on right are bigger. If e > x, then you would move up since the elements on up are smaller. But the implementation would be more cumbersome I guess.
@gavin85354 жыл бұрын
Or we can start at bottom left.
@lifecodesher58184 жыл бұрын
yaarr conditions sahi kro apni
@lifecodesher58184 жыл бұрын
this condition is wrong i guess it should be opposite
@subhashchaudhary70035 жыл бұрын
Improve sound quality ... It's irritating, sounds when you stop and start back