Search in a row wise and column wise sorted matrix | GeeksforGeeks

  Рет қаралды 51,215

GeeksforGeeks

GeeksforGeeks

Күн бұрын

Пікірлер: 19
@egor.okhterov
@egor.okhterov 3 жыл бұрын
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.
@prateekrai665
@prateekrai665 3 жыл бұрын
Awesome explanation. :)
@mitakshichandna172
@mitakshichandna172 3 жыл бұрын
why didnt we use else if instead of second if statement?:(
@ankitsharma8221
@ankitsharma8221 5 жыл бұрын
Awesome explanation!
@jeevanadhikari1588
@jeevanadhikari1588 7 жыл бұрын
Can you please show the derivation of time complexity for this algorithm to O(n)
@rajvijay3276
@rajvijay3276 6 жыл бұрын
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).
@ravindraPratapsingh7
@ravindraPratapsingh7 6 жыл бұрын
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).
@pranavamjks
@pranavamjks 5 жыл бұрын
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-in
@ksuman-in 7 жыл бұрын
when finding the first column of the value then not find the accurate value for example I'm finding 15 then not found.
@SaurabhKumar-th3gm
@SaurabhKumar-th3gm 7 жыл бұрын
Can We start from bottom left most element.
@amarbathwal1226
@amarbathwal1226 7 жыл бұрын
Saurabh Kumar yes u can
@harishkulkarni7244
@harishkulkarni7244 7 жыл бұрын
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.
@gavin8535
@gavin8535 4 жыл бұрын
Or we can start at bottom left.
@lifecodesher5818
@lifecodesher5818 4 жыл бұрын
yaarr conditions sahi kro apni
@lifecodesher5818
@lifecodesher5818 4 жыл бұрын
this condition is wrong i guess it should be opposite
@subhashchaudhary7003
@subhashchaudhary7003 5 жыл бұрын
Improve sound quality ... It's irritating, sounds when you stop and start back
@anubhavc4026
@anubhavc4026 6 жыл бұрын
Wrong method. Try finding 33 in your example.
@rajvijay3276
@rajvijay3276 6 жыл бұрын
Please try tracing it, It's right. 40->30->35->25->29->33
@pramodkumarkar8153
@pramodkumarkar8153 5 жыл бұрын
working correctly for 33 also.
Maximum size square sub-matrix with all 1s | GeeksforGeeks
6:02
GeeksforGeeks
Рет қаралды 42 М.
BS-27. Median in a Row Wise Sorted Matrix
23:13
take U forward
Рет қаралды 116 М.
Their Boat Engine Fell Off
0:13
Newsflare
Рет қаралды 15 МЛН
Хаги Ваги говорит разными голосами
0:22
Фани Хани
Рет қаралды 2,2 МЛН
$1 vs $500,000 Plane Ticket!
12:20
MrBeast
Рет қаралды 122 МЛН
Search an element in sorted Matrix( row and column sorted)
11:09
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 22 М.
Print unique rows in a given boolean matrix | GeeksforGeeks
14:56
GeeksforGeeks
Рет қаралды 13 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
BS-25. Search in a 2D Matrix - II  |  Binary Search on 2D
15:29
take U forward
Рет қаралды 91 М.
BS-24. Search in a 2D Matrix - I | Binary Search of 2D
15:42
take U forward
Рет қаралды 130 М.
A* (A Star) Search Algorithm - Computerphile
14:04
Computerphile
Рет қаралды 1,2 МЛН
2D Array Row Wise Access Is Faster Than Column Wise
9:00
CppNuts
Рет қаралды 1,7 М.
But what is a neural network? | Deep learning chapter 1
18:40
3Blue1Brown
Рет қаралды 18 МЛН
Their Boat Engine Fell Off
0:13
Newsflare
Рет қаралды 15 МЛН