diff --git a/d4/db6/reverse__binary__tree_8cpp.html b/d4/db6/reverse__binary__tree_8cpp.html index 416be9d13..6b3673504 100644 --- a/d4/db6/reverse__binary__tree_8cpp.html +++ b/d4/db6/reverse__binary__tree_8cpp.html @@ -184,11 +184,11 @@ Functions

main function

Returns
0 on exit
-
252 {
-
253 test(); // run self-test implementations
-
254 return 0;
-
255}
-
static void test()
Function to test the correctness of the Tree Reversal.
Definition reverse_binary_tree.cpp:242
+
270 {
+
271 test(); // run self-test implementations
+
272 return 0;
+
273}
+
static void test()
Function to test the correctness of the Tree Reversal.
Definition reverse_binary_tree.cpp:260
Here is the call graph for this function:
@@ -224,11 +224,11 @@ Here is the call graph for this function:

< Single element test

< No element test

< Correct reversal test

-
242 {
-
243 tests::test1(); ///< Single element test
-
244 tests::test2(); ///< No element test
-
245 tests::test3(); ///< Correct reversal test
-
246}
+
260 {
+
261 tests::test1(); ///< Single element test
+
262 tests::test2(); ///< No element test
+
263 tests::test3(); ///< Correct reversal test
+
264}
void test1()
A Test to check an simple case.
Definition array_left_rotation.cpp:75
void test3()
A Test to check an invalid shift value.
Definition array_left_rotation.cpp:105
void test2()
A Test to check an empty vector.
Definition array_left_rotation.cpp:90
diff --git a/dd/d03/classoperations__on__datastructures_1_1reverse__binary__tree_1_1_binary_tree-members.html b/dd/d03/classoperations__on__datastructures_1_1reverse__binary__tree_1_1_binary_tree-members.html index ecff98e1d..8c90ef006 100644 --- a/dd/d03/classoperations__on__datastructures_1_1reverse__binary__tree_1_1_binary_tree-members.html +++ b/dd/d03/classoperations__on__datastructures_1_1reverse__binary__tree_1_1_binary_tree-members.html @@ -111,14 +111,17 @@ $(function(){initNavTree('de/dcf/classoperations__on__datastructures_1_1reverse_

This is the complete list of members for operations_on_datastructures::reverse_binary_tree::BinaryTree, including all inherited members.

- - - - + + + + + + +
add(int64_t data)operations_on_datastructures::reverse_binary_tree::BinaryTreeinline
BinaryTree()operations_on_datastructures::reverse_binary_tree::BinaryTreeinline
BinaryTree(int64_t data)operations_on_datastructures::reverse_binary_tree::BinaryTreeinlineexplicit
get_level_order()operations_on_datastructures::reverse_binary_tree::BinaryTreeinline
insert(int64_t data, Node *pivot)operations_on_datastructures::reverse_binary_tree::BinaryTreeinlineprivate
BinaryTree(const BinaryTree &)=delete (defined in operations_on_datastructures::reverse_binary_tree::BinaryTree)operations_on_datastructures::reverse_binary_tree::BinaryTreeprivate
BinaryTree()operations_on_datastructures::reverse_binary_tree::BinaryTreeinline
BinaryTree(int64_t data)operations_on_datastructures::reverse_binary_tree::BinaryTreeinlineexplicit
get_level_order()operations_on_datastructures::reverse_binary_tree::BinaryTreeinline
insert(int64_t data, Node *pivot)operations_on_datastructures::reverse_binary_tree::BinaryTreeinlineprivate
operator=(const BinaryTree &)=delete (defined in operations_on_datastructures::reverse_binary_tree::BinaryTree)operations_on_datastructures::reverse_binary_tree::BinaryTreeprivate
print()operations_on_datastructures::reverse_binary_tree::BinaryTreeinline
reverse()operations_on_datastructures::reverse_binary_tree::BinaryTreeinline
reverseBinaryTree(Node *pivot)operations_on_datastructures::reverse_binary_tree::BinaryTreeinlineprivate
rootoperations_on_datastructures::reverse_binary_tree::BinaryTreeprivate
~BinaryTree() (defined in operations_on_datastructures::reverse_binary_tree::BinaryTree)operations_on_datastructures::reverse_binary_tree::BinaryTreeinline
diff --git a/de/dcf/classoperations__on__datastructures_1_1reverse__binary__tree_1_1_binary_tree.html b/de/dcf/classoperations__on__datastructures_1_1reverse__binary__tree_1_1_binary_tree.html index 463b9a7b6..12584aadc 100644 --- a/de/dcf/classoperations__on__datastructures_1_1reverse__binary__tree_1_1_binary_tree.html +++ b/de/dcf/classoperations__on__datastructures_1_1reverse__binary__tree_1_1_binary_tree.html @@ -149,6 +149,12 @@ Private Member Functions NodereverseBinaryTree (Node *pivot)  Reverses a Binary Tree recursively by swapping the left and right subtrees and their children.
  +BinaryTree (const BinaryTree &)=delete +  + +BinaryTreeoperator= (const BinaryTree &)=delete +  @@ -184,7 +190,7 @@ Private Attributes

Creates a BinaryTree with a root pointing to NULL.

-
98{ root = nullptr; }
+
101{ root = nullptr; }
Node * root
Pointer to root node of Binary Tree.
Definition reverse_binary_tree.cpp:54
@@ -213,12 +219,55 @@ Private Attributes

Creates a BinaryTree with a root with an initial value.

-
102{ root = new Node(data); }
+
105{ root = new Node(data); }
int data[MAX]
test data
Definition hash_search.cpp:24
Definition linkedlist_implentation_usingarray.cpp:14
+ +

◆ ~BinaryTree()

+ +
+
+

Private Attributes

+ + + + +
+ + + + + + + +
operations_on_datastructures::reverse_binary_tree::BinaryTree::~BinaryTree ()
+
+inline
+
+
107 {
+
108 std::vector<Node*> nodes;
+
109 nodes.emplace_back(root);
+
110 while (!nodes.empty()) {
+
111 const auto cur_node = nodes.back();
+
112 nodes.pop_back();
+
113 if (cur_node) {
+
114 nodes.emplace_back(cur_node->left);
+
115 nodes.emplace_back(cur_node->right);
+
116 delete cur_node;
+
117 }
+
118 }
+
119 }
+
T back(T... args)
+
T emplace_back(T... args)
+
T empty(T... args)
+
T pop_back(T... args)
+ +
+
+

Member Function Documentation

◆ add()

@@ -244,7 +293,7 @@ Private Attributes

Adds a new Node to the Binary Tree.

-
106{ root = insert(data, root); }
+
124{ root = insert(data, root); }
Node * insert(int64_t data, Node *pivot)
inserts a node in the Binary Tree, with the behaviouur of a Binary Search Tree.
Definition reverse_binary_tree.cpp:65
Here is the call graph for this function:
@@ -289,32 +338,30 @@ Here is the call graph for this function:

< Insert left node

< Insert right node

Add nodes while Tree is not empty

-
121 {
-
122 std::vector<int64_t> data; ///< Result vector of int
-
123 if (root == nullptr) {
-
124 return data; ///< Return empty vector if root is Invalid
-
125 }
-
126 std::queue<Node*> nodes; ///< Queue of the nodes in the tree
-
127 nodes.push(root); ///< Insert root into the queue
-
128 while (!nodes.empty()) {
-
129 Node* temp = nodes.front(); ///< Copy the first element
-
130 data.push_back(temp->data); ///< Add the element to the data
-
131 nodes.pop(); ///< Remove element
-
132 if (temp->left != nullptr) {
-
133 nodes.push(temp->left); ///< Insert left node
-
134 }
-
135 if (temp->right != nullptr) {
-
136 nodes.push(temp->right); ///< Insert right node
-
137 }
-
138 } /// Add nodes while Tree is not empty
-
139 return data;
-
140 }
-
T empty(T... args)
+
139 {
+
140 std::vector<int64_t> data; ///< Result vector of int
+
141 if (root == nullptr) {
+
142 return data; ///< Return empty vector if root is Invalid
+
143 }
+
144 std::queue<Node*> nodes; ///< Queue of the nodes in the tree
+
145 nodes.push(root); ///< Insert root into the queue
+
146 while (!nodes.empty()) {
+
147 Node* temp = nodes.front(); ///< Copy the first element
+
148 data.push_back(temp->data); ///< Add the element to the data
+
149 nodes.pop(); ///< Remove element
+
150 if (temp->left != nullptr) {
+
151 nodes.push(temp->left); ///< Insert left node
+
152 }
+
153 if (temp->right != nullptr) {
+
154 nodes.push(temp->right); ///< Insert right node
+
155 }
+
156 } /// Add nodes while Tree is not empty
+
157 return data;
+
158 }
T front(T... args)
T pop(T... args)
T push(T... args)
-
Here is the call graph for this function:
@@ -410,14 +457,14 @@ Here is the call graph for this function:
Returns
void

Print each element in the tree

Print newline

-
146 {
-
147 for (int i : get_level_order()) {
-
148 std::cout << i << " "; /// Print each element in the tree
-
149 }
-
150 std::cout << "\n"; /// Print newline
-
151 }
+
164 {
+
165 for (int i : get_level_order()) {
+
166 std::cout << i << " "; /// Print each element in the tree
+
167 }
+
168 std::cout << "\n"; /// Print newline
+
169 }
-
std::vector< int64_t > get_level_order()
Level order traversal of a tree consists of visiting its elements, top to bottom, left to right....
Definition reverse_binary_tree.cpp:121
+
std::vector< int64_t > get_level_order()
Level order traversal of a tree consists of visiting its elements, top to bottom, left to right....
Definition reverse_binary_tree.cpp:139
Here is the call graph for this function:
@@ -449,7 +496,7 @@ Here is the call graph for this function:

Reverses the Binary Tree

-
+
Node * reverseBinaryTree(Node *pivot)
Reverses a Binary Tree recursively by swapping the left and right subtrees and their children.
Definition reverse_binary_tree.cpp:84
Here is the call graph for this function: