diff --git a/d1/dd7/union__of__two__arrays_8cpp__incl.map b/d1/dd7/union__of__two__arrays_8cpp__incl.map new file mode 100644 index 000000000..4c7099a03 --- /dev/null +++ b/d1/dd7/union__of__two__arrays_8cpp__incl.map @@ -0,0 +1,7 @@ + + + + + + + diff --git a/d1/dd7/union__of__two__arrays_8cpp__incl.md5 b/d1/dd7/union__of__two__arrays_8cpp__incl.md5 new file mode 100644 index 000000000..dfc27b398 --- /dev/null +++ b/d1/dd7/union__of__two__arrays_8cpp__incl.md5 @@ -0,0 +1 @@ +52a6e80058339e8c1ccdf2935ebaf292 \ No newline at end of file diff --git a/d1/dd7/union__of__two__arrays_8cpp__incl.svg b/d1/dd7/union__of__two__arrays_8cpp__incl.svg new file mode 100644 index 000000000..c14d8af53 --- /dev/null +++ b/d1/dd7/union__of__two__arrays_8cpp__incl.svg @@ -0,0 +1,83 @@ + + + + + + +operations_on_datastructures/union_of_two_arrays.cpp + + + +Node1 + + +operations_on_datastructures +/union_of_two_arrays.cpp + + + + + +Node2 + + +algorithm + + + + + +Node1->Node2 + + + + + +Node3 + + +cassert + + + + + +Node1->Node3 + + + + + +Node4 + + +iostream + + + + + +Node1->Node4 + + + + + +Node5 + + +vector + + + + + +Node1->Node5 + + + + + diff --git a/d5/d88/md__d_i_r_e_c_t_o_r_y.html b/d5/d88/md__d_i_r_e_c_t_o_r_y.html index a5db82e7a..72d4366e4 100644 --- a/d5/d88/md__d_i_r_e_c_t_o_r_y.html +++ b/d5/d88/md__d_i_r_e_c_t_o_r_y.html @@ -373,7 +373,7 @@ Operations On Datastructures
  • Reverse Binary Tree
  • Selectionsortlinkedlist
  • Trie Multiple Search
  • -
  • Union Of 2 Arrays
  • +
  • Union Of Two Arrays
  • Others

    diff --git a/d8/d9c/union__of__two__arrays_8cpp.html b/d8/d9c/union__of__two__arrays_8cpp.html new file mode 100644 index 000000000..aa094febe --- /dev/null +++ b/d8/d9c/union__of__two__arrays_8cpp.html @@ -0,0 +1,249 @@ + + + + + + + +Algorithms_in_C++: operations_on_datastructures/union_of_two_arrays.cpp File Reference + + + + + + + + + + + + + + + +
    +
    + + + + + + +
    +
    Algorithms_in_C++ 1.0.0 +
    +
    Set of algorithms implemented in C++.
    +
    +
    + + + + + + + +
    +
    + +
    +
    +
    + +
    + +
    +
    + + +
    + +
    + +
    + +
    union_of_two_arrays.cpp File Reference
    +
    +
    + +

    Implementation for the Union of two sorted Arrays algorithm. +More...

    +
    #include <algorithm>
    +#include <cassert>
    +#include <iostream>
    +#include <vector>
    +
    +Include dependency graph for union_of_two_arrays.cpp:
    +
    +
    +
    +
    +
    + + + + + + + +

    +Namespaces

    namespace  operations_on_datastructures
     for std::vector
     
    namespace  tests
     Testcases to check Reversal of Binary Tree.
     
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    +Functions

    void operations_on_datastructures::print (const std::vector< int32_t > &array)
     Prints the values of a vector sequentially, ending with a newline character. More...
     
    std::vector< int32_t > operations_on_datastructures::get_union (const std::vector< int32_t > &first, const std::vector< int32_t > &second)
     Gets the union of two sorted arrays, and returns them in a vector. More...
     
    void tests::test1 ()
     < Use the BinaryTree More...
     
    void tests::test2 ()
     A Test to check an edge case (NULL root element) More...
     
    void tests::test3 ()
     A Test to check correct reversal of a Binary Tree. More...
     
    void tests::test4 ()
     A Test to check correct functionality with duplicate values. More...
     
    void tests::test5 ()
     A Test to check correct functionality with a harder test case. More...
     
    void tests::test6 ()
     A Test to check correct functionality with an array sorted using std::sort. More...
     
    static void test ()
     Function to test the correctness of get_union() function. More...
     
    int main ()
     main function More...
     
    +

    Detailed Description

    +

    Implementation for the Union of two sorted Arrays algorithm.

    +

    The Union of two arrays is the collection of all the unique elements in the first array, combined with all of the unique elements of a second array. This implementation uses ordered arrays, and an algorithm to correctly order them and return the result as a new array (vector).

    Author
    Alvin
    +

    Function Documentation

    + +

    ◆ main()

    + +
    +
    + + + + + + + + +
    int main (void )
    +
    + +

    main function

    +
    Returns
    0 on exit
    +
    216 {
    +
    217 test(); // run self-test implementations
    +
    218 return 0;
    +
    219}
    +
    static void test()
    Function to test the correctness of get_union() function.
    Definition: union_of_two_arrays.cpp:203
    +
    +Here is the call graph for this function:
    +
    +
    +
    +
    + +
    +
    + +

    ◆ test()

    + +
    +
    + + + + + +
    + + + + + + + +
    static void test ()
    +
    +static
    +
    + +

    Function to test the correctness of get_union() function.

    +
    Returns
    void
    +
    203 {
    +
    204 tests::test1();
    +
    205 tests::test2();
    +
    206 tests::test3();
    +
    207 tests::test4();
    +
    208 tests::test5();
    +
    209 tests::test6();
    +
    210}
    +
    void test1()
    < Use the BinaryTree
    Definition: reverse_binary_tree.cpp:167
    +
    void test4()
    A Test to check correct functionality with duplicate values.
    Definition: union_of_two_arrays.cpp:149
    +
    void test3()
    A Test to check correct reversal of a Binary Tree.
    Definition: reverse_binary_tree.cpp:212
    +
    void test6()
    A Test to check correct functionality with an array sorted using std::sort.
    Definition: union_of_two_arrays.cpp:182
    +
    void test2()
    A Test to check an edge case (NULL root element)
    Definition: reverse_binary_tree.cpp:191
    +
    void test5()
    A Test to check correct functionality with a harder test case.
    Definition: union_of_two_arrays.cpp:165
    +
    +Here is the call graph for this function:
    +
    +
    +
    +
    + +
    +
    +
    +
    + + + + diff --git a/d8/d9c/union__of__two__arrays_8cpp.js b/d8/d9c/union__of__two__arrays_8cpp.js new file mode 100644 index 000000000..02f2d961f --- /dev/null +++ b/d8/d9c/union__of__two__arrays_8cpp.js @@ -0,0 +1,13 @@ +var union__of__two__arrays_8cpp = +[ + [ "get_union", "d8/d9c/union__of__two__arrays_8cpp.html#a2b8ff06a84b041457873840bf82e2d74", null ], + [ "main", "d8/d9c/union__of__two__arrays_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4", null ], + [ "print", "d8/d9c/union__of__two__arrays_8cpp.html#a6109193567a5b7e36a27f2b4865fce20", null ], + [ "test", "d8/d9c/union__of__two__arrays_8cpp.html#aa8dca7b867074164d5f45b0f3851269d", null ], + [ "test1", "d8/d9c/union__of__two__arrays_8cpp.html#a167c24bd817469ae47358d12e034f2d5", null ], + [ "test2", "d8/d9c/union__of__two__arrays_8cpp.html#abdd77344d4af8fd56d14a5cabbf2f669", null ], + [ "test3", "d8/d9c/union__of__two__arrays_8cpp.html#aa515639572647508b94986489aab6d76", null ], + [ "test4", "d8/d9c/union__of__two__arrays_8cpp.html#a2b9769e44683dcb67fe1083ad91e134d", null ], + [ "test5", "d8/d9c/union__of__two__arrays_8cpp.html#af7b81d7a1534216af6a36a80135beb86", null ], + [ "test6", "d8/d9c/union__of__two__arrays_8cpp.html#aacafde185abd8670abee51157f273dc2", null ] +]; \ No newline at end of file diff --git a/d8/d9c/union__of__two__arrays_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map b/d8/d9c/union__of__two__arrays_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map new file mode 100644 index 000000000..963d3ffb5 --- /dev/null +++ b/d8/d9c/union__of__two__arrays_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/d8/d9c/union__of__two__arrays_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 b/d8/d9c/union__of__two__arrays_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 new file mode 100644 index 000000000..b68d2ff23 --- /dev/null +++ b/d8/d9c/union__of__two__arrays_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 @@ -0,0 +1 @@ +dd7e1d2eb4a0e958401a396a3f72dc22 \ No newline at end of file diff --git a/d8/d9c/union__of__two__arrays_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg b/d8/d9c/union__of__two__arrays_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg new file mode 100644 index 000000000..79c8f69a0 --- /dev/null +++ b/d8/d9c/union__of__two__arrays_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg @@ -0,0 +1,299 @@ + + + + + + +test + + + +Node1 + + +test + + + + + +Node2 + + +tests::test1 + + + + + +Node1->Node2 + + + + + +Node4 + + +tests::test2 + + + + + +Node1->Node4 + + + + + +Node5 + + +tests::test3 + + + + + +Node1->Node5 + + + + + +Node6 + + +tests::test4 + + + + + +Node1->Node6 + + + + + +Node13 + + +tests::test5 + + + + + +Node1->Node13 + + + + + +Node14 + + +tests::test6 + + + + + +Node1->Node14 + + + + + +Node3 + + +std::vector::size + + + + + +Node2->Node3 + + + + + +Node4->Node3 + + + + + +Node7 + + +operations_on_datastructures +::get_union + + + + + +Node6->Node7 + + + + + +Node10 + + +print + + + + + +Node6->Node10 + + + + + +Node7->Node3 + + + + + +Node8 + + +std::vector::back + + + + + +Node7->Node8 + + + + + +Node9 + + +std::vector::push_back + + + + + +Node7->Node9 + + + + + +Node11 + + +std::endl + + + + + +Node10->Node11 + + + + + +Node12 + + +is_prime + + + + + +Node10->Node12 + + + + + +Node13->Node7 + + + + + +Node13->Node10 + + + + + +Node14->Node7 + + + + + +Node14->Node10 + + + + + +Node15 + + +std::vector::begin + + + + + +Node14->Node15 + + + + + +Node16 + + +std::vector::end + + + + + +Node14->Node16 + + + + + +Node17 + + +std::sort + + + + + +Node14->Node17 + + + + + diff --git a/d8/d9c/union__of__two__arrays_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map b/d8/d9c/union__of__two__arrays_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map new file mode 100644 index 000000000..2290ba5d5 --- /dev/null +++ b/d8/d9c/union__of__two__arrays_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/d8/d9c/union__of__two__arrays_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 b/d8/d9c/union__of__two__arrays_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 new file mode 100644 index 000000000..f6063aa31 --- /dev/null +++ b/d8/d9c/union__of__two__arrays_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 @@ -0,0 +1 @@ +91a255ed58ff67d3fda69b096a388299 \ No newline at end of file diff --git a/d8/d9c/union__of__two__arrays_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg b/d8/d9c/union__of__two__arrays_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg new file mode 100644 index 000000000..c0f61ecff --- /dev/null +++ b/d8/d9c/union__of__two__arrays_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg @@ -0,0 +1,402 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +main + + + +Node1 + + +main + + + + + +Node2 + + +test + + + + + +Node1->Node2 + + + + + +Node3 + + +tests::test1 + + + + + +Node2->Node3 + + + + + +Node5 + + +tests::test2 + + + + + +Node2->Node5 + + + + + +Node6 + + +tests::test3 + + + + + +Node2->Node6 + + + + + +Node7 + + +tests::test4 + + + + + +Node2->Node7 + + + + + +Node14 + + +tests::test5 + + + + + +Node2->Node14 + + + + + +Node15 + + +tests::test6 + + + + + +Node2->Node15 + + + + + +Node4 + + +std::vector::size + + + + + +Node3->Node4 + + + + + +Node5->Node4 + + + + + +Node8 + + +operations_on_datastructures +::get_union + + + + + +Node7->Node8 + + + + + +Node11 + + +print + + + + + +Node7->Node11 + + + + + +Node8->Node4 + + + + + +Node9 + + +std::vector::back + + + + + +Node8->Node9 + + + + + +Node10 + + +std::vector::push_back + + + + + +Node8->Node10 + + + + + +Node12 + + +std::endl + + + + + +Node11->Node12 + + + + + +Node13 + + +is_prime + + + + + +Node11->Node13 + + + + + +Node14->Node8 + + + + + +Node14->Node11 + + + + + +Node15->Node8 + + + + + +Node15->Node11 + + + + + +Node16 + + +std::vector::begin + + + + + +Node15->Node16 + + + + + +Node17 + + +std::vector::end + + + + + +Node15->Node17 + + + + + +Node18 + + +std::sort + + + + + +Node15->Node18 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/d8/d9c/union__of__two__arrays_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph_org.svg b/d8/d9c/union__of__two__arrays_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph_org.svg new file mode 100644 index 000000000..ca6fa2360 --- /dev/null +++ b/d8/d9c/union__of__two__arrays_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph_org.svg @@ -0,0 +1,314 @@ + + + + + + +main + + + +Node1 + + +main + + + + + +Node2 + + +test + + + + + +Node1->Node2 + + + + + +Node3 + + +tests::test1 + + + + + +Node2->Node3 + + + + + +Node5 + + +tests::test2 + + + + + +Node2->Node5 + + + + + +Node6 + + +tests::test3 + + + + + +Node2->Node6 + + + + + +Node7 + + +tests::test4 + + + + + +Node2->Node7 + + + + + +Node14 + + +tests::test5 + + + + + +Node2->Node14 + + + + + +Node15 + + +tests::test6 + + + + + +Node2->Node15 + + + + + +Node4 + + +std::vector::size + + + + + +Node3->Node4 + + + + + +Node5->Node4 + + + + + +Node8 + + +operations_on_datastructures +::get_union + + + + + +Node7->Node8 + + + + + +Node11 + + +print + + + + + +Node7->Node11 + + + + + +Node8->Node4 + + + + + +Node9 + + +std::vector::back + + + + + +Node8->Node9 + + + + + +Node10 + + +std::vector::push_back + + + + + +Node8->Node10 + + + + + +Node12 + + +std::endl + + + + + +Node11->Node12 + + + + + +Node13 + + +is_prime + + + + + +Node11->Node13 + + + + + +Node14->Node8 + + + + + +Node14->Node11 + + + + + +Node15->Node8 + + + + + +Node15->Node11 + + + + + +Node16 + + +std::vector::begin + + + + + +Node15->Node16 + + + + + +Node17 + + +std::vector::end + + + + + +Node15->Node17 + + + + + +Node18 + + +std::sort + + + + + +Node15->Node18 + + + + + diff --git a/d9/df4/namespacetests.html b/d9/df4/namespacetests.html index 693345a6f..7d10808e4 100644 --- a/d9/df4/namespacetests.html +++ b/d9/df4/namespacetests.html @@ -110,9 +110,19 @@ Functions void test3 ()  A Test to check correct reversal of a Binary Tree. More...
      +void test4 () + A Test to check correct functionality with duplicate values. More...
    +  +void test5 () + A Test to check correct functionality with a harder test case. More...
    +  +void test6 () + A Test to check correct functionality with an array sorted using std::sort. More...

    Detailed Description

    Testcases to check Reversal of Binary Tree.

    +

    Testcases to check Union of Two Arrays.

    Function Documentation

    ◆ test1()

    @@ -130,10 +140,16 @@ Functions

    < Use the BinaryTree

    -

    A Test to check an edge case (single element reversal)

    +

    A Test to check an edge case (two empty arrays)

    +

    A Test to check an edge case (single element reversal)

    +
    Returns
    void

    < Check for equal sizes

    < Ensure that there is only one element

    < Check if both elements are same

    +

    < Check if result is empty

    +

    < Should only print newline

    +

    < Check if result is empty

    +

    < Should only print newline

    167 {
    168 BinaryTree bst;
    169 std::vector<int64_t> pre_reversal, post_reversal;
    @@ -183,8 +199,14 @@ Here is the call graph for this function:

    A Test to check an edge case (NULL root element)

    +

    A Test to check an edge case (one empty array)

    +
    Returns
    void

    < Check for equal sizes

    < Ensure that there is only one element

    +

    < Check if result is equal to b

    +

    < Should print 2 3

    +

    < Check if result is equal to b

    +

    < Should print 2 3

    191 {
    192 BinaryTree bst;
    193 std::vector<int64_t> pre_reversal, post_reversal;
    @@ -228,8 +250,14 @@ Here is the call graph for this function:

    A Test to check correct reversal of a Binary Tree.

    +

    A Test to check correct functionality with a simple test case.

    +
    Returns
    void

    < Check for equality

    < Check for equality

    +

    < Check if result is correct

    +

    < Should print 2 3 4 6

    +

    < Check if result is correct

    +

    < Should print 2 3 4 6

    212 {
    213 BinaryTree bst;
    214 std::vector<int64_t> pre_reversal, post_reversal;
    @@ -256,6 +284,137 @@ Here is the call graph for this function:
    235 std::cout << "TEST PASSED!\n\n";
    236}
    + + + +

    ◆ test4()

    + +
    +
    + + + + + + + +
    void tests::test4 ()
    +
    + +

    A Test to check correct functionality with duplicate values.

    +
    Returns
    void
    +

    < Check if result is correct

    +

    < Should print 2 3 4 6 7

    +
    149 {
    +
    150 std::cout << "TEST CASE 4\n";
    +
    151 std::cout << "Intialized a = {4, 6, 6, 7} b = {2, 3, 4}\n";
    +
    152 std::cout << "Expected result: {2, 3, 4, 6, 7}\n";
    +
    153 std::vector<int32_t> a = {4, 6, 6, 7};
    +
    154 std::vector<int32_t> b = {2, 3, 4};
    + +
    156 std::vector<int32_t> expected = {2, 3, 4, 6, 7};
    +
    157 assert(result == expected); ///< Check if result is correct
    +
    158 print(result); ///< Should print 2 3 4 6 7
    +
    159 std::cout << "TEST PASSED!\n\n";
    +
    160}
    +
    uint64_t result(uint64_t n)
    Definition: fibonacci_sum.cpp:76
    +
    std::vector< int32_t > get_union(const std::vector< int32_t > &first, const std::vector< int32_t > &second)
    Gets the union of two sorted arrays, and returns them in a vector.
    Definition: union_of_two_arrays.cpp:48
    +
    void print(uint32_t N, const std::vector< bool > &is_prime)
    Definition: sieve_of_eratosthenes.cpp:44
    +
    +Here is the call graph for this function:
    +
    +
    +
    +
    + +
    +
    + +

    ◆ test5()

    + +
    +
    + + + + + + + +
    void tests::test5 ()
    +
    + +

    A Test to check correct functionality with a harder test case.

    +
    Returns
    void
    +

    < Check if result is correct

    +

    < Should print 1 2 3 4 5 6 7 9

    +
    165 {
    +
    166 std::cout << "TEST CASE 5\n";
    +
    167 std::cout << "Intialized a = {1, 4, 6, 7, 9} b = {2, 3, 5}\n";
    +
    168 std::cout << "Expected result: {1, 2, 3, 4, 5, 6, 7, 9}\n";
    +
    169 std::vector<int32_t> a = {1, 4, 6, 7, 9};
    +
    170 std::vector<int32_t> b = {2, 3, 5};
    + +
    172 std::vector<int32_t> expected = {1, 2, 3, 4, 5, 6, 7, 9};
    +
    173 assert(result == expected); ///< Check if result is correct
    +
    174 print(result); ///< Should print 1 2 3 4 5 6 7 9
    +
    175 std::cout << "TEST PASSED!\n\n";
    +
    176}
    +
    +Here is the call graph for this function:
    +
    +
    +
    +
    + +
    +
    + +

    ◆ test6()

    + +
    +
    + + + + + + + +
    void tests::test6 ()
    +
    + +

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

    +
    Returns
    void
    +

    < Sort vector a

    +

    < Sort vector b

    +

    < Check if result is correct

    +

    < Should print 1 2 3 4 5 6 7 8 9 11

    +
    182 {
    +
    183 std::cout << "TEST CASE 6\n";
    +
    184 std::cout << "Intialized a = {1, 3, 3, 2, 5, 9, 4, 3, 2} ";
    +
    185 std::cout << "b = {11, 3, 7, 8, 6}\n";
    +
    186 std::cout << "Expected result: {1, 2, 3, 4, 5, 6, 7, 8, 9, 11}\n";
    +
    187 std::vector<int32_t> a = {1, 3, 3, 2, 5, 9, 4, 3, 2};
    +
    188 std::vector<int32_t> b = {11, 3, 7, 8, 6};
    +
    189 std::sort(a.begin(), a.end()); ///< Sort vector a
    +
    190 std::sort(b.begin(), b.end()); ///< Sort vector b
    + +
    192 std::vector<int32_t> expected = {1, 2, 3, 4, 5, 6, 7, 8, 9, 11};
    +
    193 assert(result == expected); ///< Check if result is correct
    +
    194 print(result); ///< Should print 1 2 3 4 5 6 7 8 9 11
    +
    195 std::cout << "TEST PASSED!\n\n";
    +
    196}
    +
    T begin(T... args)
    +
    T end(T... args)
    +
    T sort(T... args)
    +
    +Here is the call graph for this function:
    +
    +
    +
    +
    +
    diff --git a/d9/df4/namespacetests_a2b9769e44683dcb67fe1083ad91e134d_cgraph.map b/d9/df4/namespacetests_a2b9769e44683dcb67fe1083ad91e134d_cgraph.map new file mode 100644 index 000000000..eb240f5a2 --- /dev/null +++ b/d9/df4/namespacetests_a2b9769e44683dcb67fe1083ad91e134d_cgraph.map @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/d9/df4/namespacetests_a2b9769e44683dcb67fe1083ad91e134d_cgraph.md5 b/d9/df4/namespacetests_a2b9769e44683dcb67fe1083ad91e134d_cgraph.md5 new file mode 100644 index 000000000..0049de821 --- /dev/null +++ b/d9/df4/namespacetests_a2b9769e44683dcb67fe1083ad91e134d_cgraph.md5 @@ -0,0 +1 @@ +c7dd5f787f6905f619ecb2f1305e0a0c \ No newline at end of file diff --git a/d9/df4/namespacetests_a2b9769e44683dcb67fe1083ad91e134d_cgraph.svg b/d9/df4/namespacetests_a2b9769e44683dcb67fe1083ad91e134d_cgraph.svg new file mode 100644 index 000000000..d65a98bef --- /dev/null +++ b/d9/df4/namespacetests_a2b9769e44683dcb67fe1083ad91e134d_cgraph.svg @@ -0,0 +1,128 @@ + + + + + + +tests::test4 + + + +Node1 + + +tests::test4 + + + + + +Node2 + + +operations_on_datastructures +::get_union + + + + + +Node1->Node2 + + + + + +Node6 + + +print + + + + + +Node1->Node6 + + + + + +Node3 + + +std::vector::back + + + + + +Node2->Node3 + + + + + +Node4 + + +std::vector::push_back + + + + + +Node2->Node4 + + + + + +Node5 + + +std::vector::size + + + + + +Node2->Node5 + + + + + +Node7 + + +std::endl + + + + + +Node6->Node7 + + + + + +Node8 + + +is_prime + + + + + +Node6->Node8 + + + + + diff --git a/d9/df4/namespacetests_aacafde185abd8670abee51157f273dc2_cgraph.map b/d9/df4/namespacetests_aacafde185abd8670abee51157f273dc2_cgraph.map new file mode 100644 index 000000000..4d79b71c5 --- /dev/null +++ b/d9/df4/namespacetests_aacafde185abd8670abee51157f273dc2_cgraph.map @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/d9/df4/namespacetests_aacafde185abd8670abee51157f273dc2_cgraph.md5 b/d9/df4/namespacetests_aacafde185abd8670abee51157f273dc2_cgraph.md5 new file mode 100644 index 000000000..3dc77840f --- /dev/null +++ b/d9/df4/namespacetests_aacafde185abd8670abee51157f273dc2_cgraph.md5 @@ -0,0 +1 @@ +fff1ea433f7e8b2767fbb6b885ebdd98 \ No newline at end of file diff --git a/d9/df4/namespacetests_aacafde185abd8670abee51157f273dc2_cgraph.svg b/d9/df4/namespacetests_aacafde185abd8670abee51157f273dc2_cgraph.svg new file mode 100644 index 000000000..09b80c7e5 --- /dev/null +++ b/d9/df4/namespacetests_aacafde185abd8670abee51157f273dc2_cgraph.svg @@ -0,0 +1,173 @@ + + + + + + +tests::test6 + + + +Node1 + + +tests::test6 + + + + + +Node2 + + +std::vector::begin + + + + + +Node1->Node2 + + + + + +Node3 + + +std::vector::end + + + + + +Node1->Node3 + + + + + +Node4 + + +operations_on_datastructures +::get_union + + + + + +Node1->Node4 + + + + + +Node8 + + +print + + + + + +Node1->Node8 + + + + + +Node11 + + +std::sort + + + + + +Node1->Node11 + + + + + +Node5 + + +std::vector::back + + + + + +Node4->Node5 + + + + + +Node6 + + +std::vector::push_back + + + + + +Node4->Node6 + + + + + +Node7 + + +std::vector::size + + + + + +Node4->Node7 + + + + + +Node9 + + +std::endl + + + + + +Node8->Node9 + + + + + +Node10 + + +is_prime + + + + + +Node8->Node10 + + + + + diff --git a/d9/df4/namespacetests_af7b81d7a1534216af6a36a80135beb86_cgraph.map b/d9/df4/namespacetests_af7b81d7a1534216af6a36a80135beb86_cgraph.map new file mode 100644 index 000000000..fee527a81 --- /dev/null +++ b/d9/df4/namespacetests_af7b81d7a1534216af6a36a80135beb86_cgraph.map @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/d9/df4/namespacetests_af7b81d7a1534216af6a36a80135beb86_cgraph.md5 b/d9/df4/namespacetests_af7b81d7a1534216af6a36a80135beb86_cgraph.md5 new file mode 100644 index 000000000..dcee7f5db --- /dev/null +++ b/d9/df4/namespacetests_af7b81d7a1534216af6a36a80135beb86_cgraph.md5 @@ -0,0 +1 @@ +89fa3e8dc2e843084451722be443a20b \ No newline at end of file diff --git a/d9/df4/namespacetests_af7b81d7a1534216af6a36a80135beb86_cgraph.svg b/d9/df4/namespacetests_af7b81d7a1534216af6a36a80135beb86_cgraph.svg new file mode 100644 index 000000000..a61affdcf --- /dev/null +++ b/d9/df4/namespacetests_af7b81d7a1534216af6a36a80135beb86_cgraph.svg @@ -0,0 +1,128 @@ + + + + + + +tests::test5 + + + +Node1 + + +tests::test5 + + + + + +Node2 + + +operations_on_datastructures +::get_union + + + + + +Node1->Node2 + + + + + +Node6 + + +print + + + + + +Node1->Node6 + + + + + +Node3 + + +std::vector::back + + + + + +Node2->Node3 + + + + + +Node4 + + +std::vector::push_back + + + + + +Node2->Node4 + + + + + +Node5 + + +std::vector::size + + + + + +Node2->Node5 + + + + + +Node7 + + +std::endl + + + + + +Node6->Node7 + + + + + +Node8 + + +is_prime + + + + + +Node6->Node8 + + + + + diff --git a/da/d6d/namespaceoperations__on__datastructures.html b/da/d6d/namespaceoperations__on__datastructures.html index 0da573276..e51699a49 100644 --- a/da/d6d/namespaceoperations__on__datastructures.html +++ b/da/d6d/namespaceoperations__on__datastructures.html @@ -90,12 +90,24 @@ $(document).ready(function(){initNavTree('da/d6d/namespaceoperations__on__datast
    +
    +Functions
    operations_on_datastructures Namespace Reference

    for std::vector More...

    + + + + + + + + +

    +Functions

    void print (const std::vector< int32_t > &array)
     Prints the values of a vector sequentially, ending with a newline character. More...
     
    std::vector< int32_t > get_union (const std::vector< int32_t > &first, const std::vector< int32_t > &second)
     Gets the union of two sorted arrays, and returns them in a vector. More...
     

    Detailed Description

    for std::vector

    for std::priority_queue

    @@ -105,8 +117,154 @@ $(document).ready(function(){initNavTree('da/d6d/namespaceoperations__on__datast

    For assert For IO operations For std::queue

    Operations on Data Structures

    for std::count for assert for tolower for string operations for IO Operations

    -

    Operations on data structures

    -
    +

    Operations on data structures

    +

    for std::sort for assert for IO operations

    +

    Operations on Data Structures

    +

    Function Documentation

    + +

    ◆ get_union()

    + +
    +
    + + + + + + + + + + + + + + + + + + +
    std::vector< int32_t > operations_on_datastructures::get_union (const std::vector< int32_t > & first,
    const std::vector< int32_t > & second 
    )
    +
    + +

    Gets the union of two sorted arrays, and returns them in a vector.

    +

    An algorithm is used that compares the elements of the two vectors, appending the one that has a lower value, and incrementing the index for that array. If one of the arrays reaches its end, all the elements of the other are appended to the resultant vector.

    Parameters
    + + + +
    firstA std::vector of sorted integer values
    secondA std::vector of sorted integer values
    +
    +
    +
    Returns
    A std::vector of the union of the two arrays, in ascending order
    +

    < Vector to hold the union

    +

    < Index for the first array

    +

    < Index for the second array

    +

    < Length of first array

    +

    < Length of second array

    +

    < Integer to store value of the next element

    +

    < Append from first array

    +

    < Increment index of second array

    +

    < Append from second array

    +

    < Increment index of second array

    +

    < Element is the same in both

    +

    < Increment index of first array

    +

    < Increment index of second array too

    +

    < Add the element if it is unique

    +

    < Add remaining elements

    +

    < Add the element if it is unique

    +

    < Add remaining elements

    +

    < Add the element if it is unique

    +
    49 {
    +
    50 std::vector<int32_t> res; ///< Vector to hold the union
    +
    51 size_t f_index = 0; ///< Index for the first array
    +
    52 size_t s_index = 0; ///< Index for the second array
    +
    53 size_t f_length = first.size(); ///< Length of first array
    +
    54 size_t s_length = second.size(); ///< Length of second array
    +
    55 int32_t next = 0; ///< Integer to store value of the next element
    +
    56
    +
    57 while (f_index < f_length && s_index < s_length) {
    +
    58 if (first[f_index] < second[s_index]) {
    +
    59 next = first[f_index]; ///< Append from first array
    +
    60 f_index++; ///< Increment index of second array
    +
    61 } else if (first[f_index] > second[s_index]) {
    +
    62 next = second[s_index]; ///< Append from second array
    +
    63 s_index++; ///< Increment index of second array
    +
    64 } else {
    +
    65 next = first[f_index]; ///< Element is the same in both
    +
    66 f_index++; ///< Increment index of first array
    +
    67 s_index++; ///< Increment index of second array too
    +
    68 }
    +
    69 if ((res.size() == 0) || (next != res.back())) {
    +
    70 res.push_back(next); ///< Add the element if it is unique
    +
    71 }
    +
    72 }
    +
    73 while (f_index < f_length) {
    +
    74 next = first[f_index]; ///< Add remaining elements
    +
    75 if ((res.size() == 0) || (next != res.back())) {
    +
    76 res.push_back(next); ///< Add the element if it is unique
    +
    77 }
    +
    78 f_index++;
    +
    79 }
    +
    80 while (s_index < s_length) {
    +
    81 next = second[s_index]; ///< Add remaining elements
    +
    82 if ((res.size() == 0) || (next != res.back())) {
    +
    83 res.push_back(next); ///< Add the element if it is unique
    +
    84 }
    +
    85 s_index++;
    +
    86 }
    +
    87 return res;
    +
    88}
    +
    T back(T... args)
    +
    T next(T... args)
    +
    T push_back(T... args)
    +
    T size(T... args)
    + +
    +Here is the call graph for this function:
    +
    +
    +
    +
    + +
    +
    + +

    ◆ print()

    + +
    +
    + + + + + + + + +
    void operations_on_datastructures::print (const std::vector< int32_t > & array)
    +
    + +

    Prints the values of a vector sequentially, ending with a newline character.

    +
    Parameters
    + + +
    arrayReference to the array to be printed
    +
    +
    +
    Returns
    void
    +

    Print each value in the array

    +

    Print newline

    +
    30 {
    +
    31 for (int64_t i : array) {
    +
    32 std::cout << i << " "; /// Print each value in the array
    +
    33 }
    +
    34 std::cout << "\n"; /// Print newline
    +
    35}
    + +
    +
    +
    + diff --git a/dir_35422be6552f1b3672c1b6c4aba2da64.js b/dir_35422be6552f1b3672c1b6c4aba2da64.js index 2d45520f9..1539f384f 100644 --- a/dir_35422be6552f1b3672c1b6c4aba2da64.js +++ b/dir_35422be6552f1b3672c1b6c4aba2da64.js @@ -2,5 +2,6 @@ var dir_35422be6552f1b3672c1b6c4aba2da64 = [ [ "inorder_successor_of_bst.cpp", "d4/d32/inorder__successor__of__bst_8cpp.html", "d4/d32/inorder__successor__of__bst_8cpp" ], [ "reverse_binary_tree.cpp", "d4/db6/reverse__binary__tree_8cpp.html", "d4/db6/reverse__binary__tree_8cpp" ], - [ "trie_multiple_search.cpp", "d7/def/trie__multiple__search_8cpp.html", "d7/def/trie__multiple__search_8cpp" ] + [ "trie_multiple_search.cpp", "d7/def/trie__multiple__search_8cpp.html", "d7/def/trie__multiple__search_8cpp" ], + [ "union_of_two_arrays.cpp", "d8/d9c/union__of__two__arrays_8cpp.html", "d8/d9c/union__of__two__arrays_8cpp" ] ]; \ No newline at end of file diff --git a/files.html b/files.html index 01c57eb65..8e4eb6ebc 100644 --- a/files.html +++ b/files.html @@ -270,6 +270,7 @@ solve-a-rat-in-a-maze-c-java-pytho/"  inorder_successor_of_bst.cppAn implementation for finding the Inorder successor of a binary search tree Inorder successor of a node is the next node in Inorder traversal of the Binary Tree. Inorder Successor is NULL for the last node in Inorder traversal  reverse_binary_tree.cppImplementation for the Reversing a Binary Tree recursively algorithm  trie_multiple_search.cppTrie datastructure with search variants + union_of_two_arrays.cppImplementation for the Union of two sorted Arrays algorithm   others  buzz_number.cppA buzz number is a number that is either divisible by 7 or has last digit as 7  decimal_to_binary.cppFunction to convert decimal number to binary representation diff --git a/globals_func_m.html b/globals_func_m.html index aba96b79a..586e2e61e 100644 --- a/globals_func_m.html +++ b/globals_func_m.html @@ -93,7 +93,7 @@ $(document).ready(function(){initNavTree('globals_func_m.html',''); initResizabl  

    - m -