https://github.com/zpnst/different-trees
Here you will find the implementation and explanation of the following trees: Binary Tree, AVL Binary Tree, Red Black Tree, Splay Tree in C++
https://github.com/zpnst/different-trees
avl-tree binary-tree cpp20 tree-structure
Last synced: 6 months ago
JSON representation
Here you will find the implementation and explanation of the following trees: Binary Tree, AVL Binary Tree, Red Black Tree, Splay Tree in C++
- Host: GitHub
- URL: https://github.com/zpnst/different-trees
- Owner: zpnst
- Created: 2023-12-07T18:18:23.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-02-02T10:32:30.000Z (almost 2 years ago)
- Last Synced: 2025-07-03T02:03:53.220Z (6 months ago)
- Topics: avl-tree, binary-tree, cpp20, tree-structure
- Language: C++
- Homepage:
- Size: 169 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Implementation of various trees in C++

## The following trees are implemented in this repository:
1. [Binary Tree](trees/binary-tree)
2. [AVL Binary Tree](trees/avl-binary-tree)
3. [Red Black Tree](trees/red-black-tree)
4. [Splay Tree](trees/splay-tree)
Each tree has its own characteristics, which I will not describe in detail, since countless Internet resources have done it for me.
## How to draw a tree based on the output in the terminal
You need to use the level_order_print() function.
But do not confuse it with the order_print() function, it outputs the elements of the tree in order(from smaller to larger).

Next, simply restore the tree according to the simplest rules of a binary tree(>= - to the right, < - to the left), abstracting from the type of tree.
## Our example
In our example, we insert an array of numbers {100, 50, 150, 25, 55, 175, 125, 300, 1000}, and then we delete the values 150, 50 and 1000.
What will happen to a simple search tree after all the above actions:

## Navigation
To learn more about the implementation of each of the trees and their brief description, follow these paths (*I recommend in this order*):
```
trees/binary-tree
trees/avl-binary-tree
trees/red-black-tree
trees/splay-tree
```
Each folder will show the trees before and after deleting the items and briefly describe their properties
## Assembling
From the root folder "different-trees" type the following commands:
```
cmake -S . -B build
make --build build
cd build/
./comparison
```
If you did everything right, then you will get this result:
