the art of
Algorithm
Notes on Analysis and Design



Search in a Sorted Matrix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
def search(matrix,n,x):
	i,j=0,n-1
	while(i<n and j>=0):

		if matrix[i][j]==x:
            
			print (i ,j)
            break
		if matrix[i][j]<x:
			i=i+1
		elif matrix[i][j]>x:
			j=j-1
        else:
            print "Element not found"

#Driver Program to test above function
matrix=[[10, 20, 30, 40],
        [15, 25, 35, 45],
        [27, 29, 37, 48],
        [32, 33, 39, 50]]
search(matrix,4,33)