Question: Design an algorithm to search a key in a two dimensional matrix (N*M) illustrated as follows. The matrix has the property that the numbers in

 Design an algorithm to search a key in a two dimensional

Design an algorithm to search a key in a two dimensional matrix (N*M) illustrated as follows. The matrix has the property that the numbers in column are sorted in decreasing order, while the numbers in rows are sorted in increasing order. Please design and write a pseudo code to find a key in the matrix with linear efficiency. The O(N) should be no more than N + M, where N is the size for rows and M is the size for columns. Discuss the efficiency of you algorithm (O(N)) and illustrate your algorithm by searching number 71. A 5*8 matrix when N=5, M=8 in this case

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!