TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Implementation for the Reversing a Binary Tree recursively algorithm. More...
#include <cassert>
#include <iostream>
#include <queue>
#include <vector>
Go to the source code of this file.
Classes | |
struct | operations_on_datastructures::reverse_binary_tree::Node |
A Node struct that represents a single node in a Binary Tree. More... | |
class | operations_on_datastructures::reverse_binary_tree::BinaryTree |
A Binary Tree class that implements a Binary Search Tree (BST) by default. More... | |
Namespaces | |
namespace | operations_on_datastructures |
for std::vector | |
namespace | reverse_binary_tree |
Functions for the Reverse a Binary Tree implementation. | |
namespace | tests |
Testcases to check Union of Two Arrays. | |
Functions | |
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. | |
static void | test () |
Function to test the correctness of the Tree Reversal. | |
int | main () |
main function | |
Implementation for the Reversing a Binary Tree recursively algorithm.
A binary tree can be reversed by swapping the left and right child of a node at each node, starting from the root, and cascading below. This solution aims to provide an implementation of a recursive reversal of a binary tree.
Definition in file reverse_binary_tree.cpp.
int main | ( | void | ) |
main function
Definition at line 270 of file reverse_binary_tree.cpp.
|
static |
Function to test the correctness of the Tree Reversal.
< Single element test
< No element test
< Correct reversal test
Definition at line 260 of file reverse_binary_tree.cpp.