Matrix is in the form of
10 | 13 | 43 | 61 | 67 | 83
14 | 24 | 47 | 71 | 3 | 94
22 | 33 | 51 |82 | 88 | 96
27 | 41 | 52 | 84 | 92 | 99
38 | 45 | 52 | 90 | 95 | 101
105|111 |121 |133 |144 |149
Find 43,60,144
Given a 2D array with numeric values that are sorted row wise 4 column wise.Find if a value exists in the array using binary search.
I have traced it by binary search in image. 1st try: I have traced it by first finding the midpoint(51).After finding the first midpoint,I have divided the matrix in two parts. 1st part is the upper half (10-51 diagonally) and 2nd is the remaining part.Can I divide the matrix in such way(1st try)?
2nd try:I have again taken a midpoint(51) and divided into lower and upper half.Upper half and lower half taken by diagonal numbers.
I am not able to find th values that are given. Is there anyother condition through which I can find numbers:43,60,144 ?
2D array:
int no[6][6]={{10,13,43,61,67,83},
{14,24,47,71,73,94},
{22,33,51,82,88,96},
{27,41,52,84,92,99},
{38,45,60,90,95,101},
{105,111,121,133,144,149}
};