Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Implementation for the Intersection of two sorted Arrays algorithm. More...
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
Namespaces | |
namespace | operations_on_datastructures |
for std::vector | |
namespace | tests |
Testcases to check Union of Two Arrays. | |
Functions | |
void | operations_on_datastructures::print (const std::vector< int32_t > &array) |
Prints the values of a vector sequentially, ending with a newline character. | |
std::vector< int32_t > | operations_on_datastructures::get_intersection (const std::vector< int32_t > &first, const std::vector< int32_t > &second) |
Gets the intersection of two sorted arrays, and returns them in a vector. | |
void | tests::test1 () |
A Test to check an simple case. | |
void | tests::test2 () |
A Test to check an empty vector. | |
void | tests::test3 () |
A Test to check an invalid shift value. | |
void | tests::test4 () |
A Test to check a very large input. | |
void | tests::test5 () |
A Test to check a shift of zero. | |
void | tests::test6 () |
A Test to check correct functionality with an array sorted using std::sort. | |
static void | test () |
Function to test the correctness of get_intersection() function. | |
int | main () |
main function | |
Implementation for the Intersection of two sorted Arrays algorithm.
The intersection of two arrays is the collection of all the elements that are common in both the first and second arrays. This implementation uses ordered arrays, and an algorithm to correctly order them and return the result as a new array (vector).
int main | ( | void | ) |
|
static |
Function to test the correctness of get_intersection() function.