|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Searchin for an element in a sorted matrix
Hello everybody,
I have a n X n matrix. It is sorted row wise as well as column wise. Ex- | 2 4 5 6| | 3 9 11 12| | 5 13 15 17| | 8 14 19 50| Now, if I want to find 12, what is most efficient algorithm to do that using Divide and conquer? Can anybody please help? thanks |
|
#2
|
|||
|
|||
|
hi i have a solution
check the elements diagonally, if u get it u have done it else find 2 ajacent elements in the diagonal such that a[i][i] < key < a[i+1][i=1] then divide matrix in 4 parts (like 4 quadrunts) out of which u may have ur key in the 2 parts and 2 parts rejected Do apply the algorithm on remaining 2 matrices recursively. and u get the answer if u want i can write code for u. thank u bye..... ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Software Design > Searchin for an element in a sorted matrix |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|