Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Union of two arrays #1794

Merged
merged 23 commits into from
Oct 24, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c760166
Create reverse_binary_tree.cpp
alvinphilips Oct 19, 2021
cbad183
Added documentation
alvinphilips Oct 19, 2021
54143f2
Added documentation
alvinphilips Oct 19, 2021
41af1e4
Renamed tests to test
alvinphilips Oct 19, 2021
fb86292
Fixed issue with incorrect using statement
alvinphilips Oct 19, 2021
6c5794a
updating DIRECTORY.md
Oct 19, 2021
e9cd4fd
clang-format and clang-tidy fixes for fb86292d
Oct 19, 2021
b222cb2
Added Test cases
alvinphilips Oct 19, 2021
ffbbc65
Merge branch 'binary-tree' of https://github.com/polarvoid/C-Plus-Plu…
alvinphilips Oct 19, 2021
2208192
Merge branch 'master' into master
alvinphilips Oct 19, 2021
0421f55
Update operations_on_datastructures/reverse_binary_tree.cpp
alvinphilips Oct 19, 2021
657f759
Update operations_on_datastructures/reverse_binary_tree.cpp
alvinphilips Oct 19, 2021
aabd5a2
Update operations_on_datastructures/reverse_binary_tree.cpp
alvinphilips Oct 19, 2021
ff091f7
Update operations_on_datastructures/reverse_binary_tree.cpp
alvinphilips Oct 19, 2021
76255dd
Update operations_on_datastructures/reverse_binary_tree.cpp
alvinphilips Oct 19, 2021
14a26c3
Changed int to int64_t
alvinphilips Oct 19, 2021
39bb9b9
Updated documentation wording
alvinphilips Oct 19, 2021
46936a7
Merge branch 'TheAlgorithms:master' into master
alvinphilips Oct 19, 2021
1ade0de
Merge branch 'TheAlgorithms:master' into master
alvinphilips Oct 20, 2021
eb32bf7
Merge branch 'TheAlgorithms:master' into master
alvinphilips Oct 21, 2021
3954ceb
Fixed wrong integer type
alvinphilips Oct 23, 2021
2af706b
Merge branch 'master' into union-of-two-arrays
alvinphilips Oct 23, 2021
972a520
clang-format and clang-tidy fixes for 2af706b1
Oct 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
* [Inorder Successor Of Bst](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/operations_on_datastructures/inorder_successor_of_bst.cpp)
* [Intersection Of 2 Arrays](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/operations_on_datastructures/intersection_of_2_arrays.cpp)
* [Reverse A Linked List Using Recusion](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/operations_on_datastructures/reverse_a_linked_list_using_recusion.cpp)
* [Reverse Binary Tree](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/operations_on_datastructures/reverse_binary_tree.cpp)
* [Selectionsortlinkedlist](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/operations_on_datastructures/selectionsortlinkedlist.cpp)
* [Trie Multiple Search](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/operations_on_datastructures/trie_multiple_search.cpp)
* [Union Of 2 Arrays](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/operations_on_datastructures/union_of_2_arrays.cpp)
Expand Down
22 changes: 11 additions & 11 deletions operations_on_datastructures/reverse_binary_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ struct Node {
/**
* @brief Creates a new Node with some initial data
*/
Node(int _data) {
data = _data; ///< Set value of Node data
left = NULL; ///< Initialize left child to NULL
right = NULL; ///< Initialize right child to NULL
explicit Node(int _data) {
data = _data; ///< Set value of Node data
left = nullptr; ///< Initialize left child to NULL
right = nullptr; ///< Initialize right child to NULL
}
};

Expand All @@ -61,7 +61,7 @@ class BinaryTree {
* @returns Node pointer to the root
*/
Node* insert(int data, Node* pivot) {
if (pivot == NULL) {
if (pivot == nullptr) {
return new Node(data); ///< Create new node
}
if (data <= pivot->data) {
Expand All @@ -80,7 +80,7 @@ class BinaryTree {
* @returns Node pointer to root node
*/
Node* reverseBinaryTree(Node* pivot) {
if (pivot == NULL) {
if (pivot == nullptr) {
return pivot; ///< Base case
}
Node* temp = pivot->left; ///< pointer to the left subtree
Expand All @@ -93,11 +93,11 @@ class BinaryTree {
/**
* @brief Creates a BinaryTree with a root pointing to NULL.
*/
BinaryTree() { root = NULL; }
BinaryTree() { root = nullptr; }
/**
* @brief Creates a BinaryTree with a root with an initial value.
*/
BinaryTree(int data) { root = new Node(data); }
explicit BinaryTree(int data) { root = new Node(data); }
/**
* @brief Adds a new Node to the Binary Tree
*/
Expand All @@ -118,7 +118,7 @@ class BinaryTree {
*/
std::vector<int> get_level_order() {
std::vector<int> data; ///< Result vector of int
if (root == NULL) {
if (root == nullptr) {
return data; ///< Return empty vector if root is Invalid
}
std::queue<Node*> nodes; ///< Queue of the nodes in the tree
Expand All @@ -127,10 +127,10 @@ class BinaryTree {
Node* temp = nodes.front(); ///< Copy the first element
data.push_back(temp->data); ///< Add the element to the data
nodes.pop(); ///< Remove element
if (temp->left != NULL) {
if (temp->left != nullptr) {
nodes.push(temp->left); ///< Insert left node
}
if (temp->right != NULL) {
if (temp->right != nullptr) {
nodes.push(temp->right); ///< Insert right node
}
} /// Add nodes while Tree is not empty
Expand Down