i have array on 3*3 2D and every row are sorted and every colomn are sorted also
and need to apply binary search on it as best algorithm
e.g :


9 11 17
12 15 22
19 20 29

You need to sort the array twice. First time, sort the rows. When a swap is needed you need to swap all the columns on the row so that the column data stays with the rows. Then resort the array by columns. When a swap is needed you need to swap all the rows for that column. So that you will get this affect on random numbers

Unsorted array
18313 15285 21803
20551 19498 1481
12873 15650 22070


Array sorted by rows
12873 15650 22070
18313 15285 21803
20551 19498 1481


Array sorted by columns
12873 15650 22070
18313 15285 21803
20551 19498 1481
Press any key to continue . . .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.