Search 2D Matrix in a better way
Below implement a C++ program that user fewer steps than binary search algorithm for search in 2-dimensional integer matrix(array).It can be used to search array like above figure. CODE #include <iostream> using namespace std; //I define 5*5 matrix..But by this algorithm you can perform other sizes also.But need to declare in the algorithm int const rows = 5; //define matrix No.of Rows... int const columns = 5; //define matrix No.of Columns... //function of seaching elements.... void binarySearch(int matrix[5][5], int x, int start, int last, int counting, int k3, int steps[5][5], int k1, int k2, int rows) { while (start <= last) //check to stop searching... { int mid = last - (last - start) / 2; //find middle element counting = counting + 1; //counting steps... if (matrix[k3][m...