Problem statement Given a row and column sorted matrix, find an element in it. Example of row and column sorted matrix is as follows. [1,2,3,4,5 6,7,8,9,10 11,1,2,13,14,15 16,17,18,19,20 21,22,23,24,25] Analysis Since row and column are individually sorted, we can start from the leftmost bottom corner and see if the element to be searched is less than or greater than element at leftmost bottom cell element. If it is less then we move up in the same column, and if it is greater than we move right in same row.
Read full article from Algorithms and Me: Find an element in row and column sorted matrix
No comments:
Post a Comment