|
Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Implementation of Saddleback Algorithm for 2D arrays. More...
#include <cassert>#include <iostream>#include <vector>Namespaces | |
| namespace | search |
| for std::vector | |
| namespace | saddleback |
| Function for implementing Saddleback Algorithm. | |
Functions | |
| std::pair< uint32_t, uint32_t > | search::saddleback::saddleback (std::vector< std::vector< int32_t > > matrix, int32_t element) |
| static void | test () |
| Test implementations. More... | |
| int | main () |
| Main function. More... | |
Implementation of Saddleback Algorithm for 2D arrays.
Saddleback Algorithm is an algorithm that searches 2D array in linear time, i.e, O(m + n), where m is number of rows and n is number of columns of 2D array. Also, each row and column of the matrix should be sorted beforehand for this algorithm to work.
| int main | ( | void | ) |
| std::pair< uint32_t, uint32_t > search::saddleback::saddleback | ( | std::vector< std::vector< int32_t > > | matrix, |
| int32_t | element | ||
| ) |
This function implements Saddleback Algorithm, on a sorted 2D array, and finds the location of the element needed to search
| matrix | 2D matrix which is sorted on the basis of rows and columns |
| element | element to be searched |
|
static |
Test implementations.