Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
reverse_binary_tree.cpp File Reference

Implementation for the Reversing a Binary Tree recursively algorithm. More...

#include <cassert>
#include <iostream>
#include <queue>
#include <vector>
Include dependency graph for reverse_binary_tree.cpp:

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 Reversal of Binary Tree.
 

Functions

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...
 
static void test ()
 Function to test the correctness of the Tree Reversal. More...
 
int main ()
 main function More...
 

Detailed Description

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.

Author
Alvin

Function Documentation

◆ main()

int main ( void  )

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
Here is the call graph for this function:

◆ test()

static void test ( )
static

Function to test the correctness of the Tree Reversal.

< 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}
void test1()
< Use the BinaryTree
Definition: reverse_binary_tree.cpp:167
void test3()
A Test to check correct reversal of a Binary Tree.
Definition: reverse_binary_tree.cpp:212
void test2()
A Test to check an edge case (NULL root element)
Definition: reverse_binary_tree.cpp:191
Here is the call graph for this function: