A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d4/db6/reverse__binary__tree_8cpp.html below:

TheAlgorithms/C++: operations_on_datastructures/reverse_binary_tree.cpp File Reference

Loading...

Searching...

No Matches

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.

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.

◆ main()

main function

Returns
0 on exit

Definition at line 270 of file reverse_binary_tree.cpp.

270 {

272 return 0;

273}

static void test()

Function to test the correctness of the Tree Reversal.

◆ test()

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.

260 {

264}

void test1()

A Test to check an simple case.

void test3()

A Test to check an invalid shift value.

void test2()

A Test to check an empty vector.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4