a project to learn about binary tree searches
Find a file
2025-12-14 14:30:35 +01:00
src no endl.. 2025-12-13 15:50:56 +01:00
.gitignore wip: delete value from tree #1 2025-12-09 09:48:59 +01:00
CMakeLists.txt fix: forgor to update cmakelist 2025-11-24 23:46:00 +01:00
README.md add readme 2025-12-14 14:30:35 +01:00

Binary Search Tree

This project was created for me to learn about binary tree searches.

Implementation

The latest version uses the in-order predecessor, but earlier versions used the in-order successor.

In short: when deleting a node with two children, this version replaces it with the largest value from the left subtree instead of the smallest value from the right subtree.

I wrote this in C++ since its the language I use the most and want to get better at. I specifically chose C++17 because its less “bloated” than newer standards and still very common in existing codebases.

Example Output

# print initial tree (sorted list of integers)
└──25
    ├──10
    │   ├──5
    │   │   ├──2
    │   └──20
    └──40
        ├──30
        │   └──35
        └──50
            └──69
                └──420
# search for 999 and 69
999 was not found!
found 69!
# attempt to delete 5
deleted 5!
└──25
    ├──10
    │   ├──2
    │   └──20
    └──40
        ├──30
        │   └──35
        └──50
            └──69
                └──420
# attempt to delete 40
deleted 40!
└──25
    ├──10
    │   ├──2
    │   └──20
    └──35
        ├──30
        └──50
            └──69
                └──420