A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/de/dc5/intersection__of__two__arrays_8cpp.html below:

TheAlgorithms/C++: operations_on_datastructures/intersection_of_two_arrays.cpp File Reference

Loading...

Searching...

No Matches

Implementation for the Intersection of two sorted Arrays algorithm. More...

#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>

Go to the source code of this file.

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
std::vector< int32_t >  tests::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::print (const std::vector< int32_t > &array)   Prints the values of a vector sequentially, ending with a newline character.

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).

See also
union_of_two_arrays.cpp

Definition in file intersection_of_two_arrays.cpp.

◆ main()

main function

Returns
0 on exit

Definition at line 200 of file intersection_of_two_arrays.cpp.

200 {

202 return 0;

203}

static void test()

Function to test the correctness of get_intersection() function.

◆ test()

Function to test the correctness of get_intersection() function.

Returns
void

Definition at line 187 of file intersection_of_two_arrays.cpp.

187 {

194}

void test1()

A Test to check an simple case.

void test4()

A Test to check a very large input.

void test3()

A Test to check an invalid shift value.

void test6()

A Test to check correct functionality with an array sorted using std::sort.

void test2()

A Test to check an empty vector.

void test5()

A Test to check a shift of zero.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4