Skip to content

Binary Search Tree, Balanced Binary Tree and Heap Implementations in C++

License

Notifications You must be signed in to change notification settings

icliberen/binary-heap-trees

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Binary Search Tree, Balanced Binary Tree and Heap Implementations in C++

This project demonstrates multiple tree-based data structures in C++:

  • Binary Search Tree (BST):

    • Supports insertion, deletion and a visual display (both balanced and level order).
    • Displays the maximum element along with its level.
  • Balanced Binary Tree:

    • Uses a balanced insertion method.
    • Allows deletion of the last inserted element.
    • Displays the tree and checks properties such as full, complete and perfect.
  • Heap:

    • Implements both MinHeap and MaxHeap functionalities.
    • Visualizes the heap as a tree with / and \ representing parent-child connections.
    • Allows dynamic switching between MinHeap and MaxHeap even after creation.

Features

  • Insertion & Deletion: Easily add and remove elements in each data structure.
  • Visual Display:
    • Structured top-down visualization for both trees and heap.
    • Level order (BFS) traversal for BST.
  • Heap Type Switching:
    • Change between min-heap and max-heap on the fly.
  • Tree Property Analysis: Check if binary trees are full, complete or perfect.
  • Robust Input Handling: Ensures only valid integer inputs are accepted.

Prerequisites

  • For Building from Source:

    • Visual Studio (2019 or later with C++ development)
    • Alternatively, a C++ compiler such as g++ (for command-line builds)
  • For Running Pre-Built Releases:

    • No development tools required, just the executable for windows operating system

How to Run the Application

Using Visual Studio

  1. Clone the Repository:
    git clone https://github.com/icliberen/binary-heap-trees.git
    

Using terminal

  1. Clone the Repository:

    git clone https://github.com/icliberen/binary-heap-trees.git
    
  2. Compile the Code:

    g++ -o binary_heap_trees main.cpp
    
  3. Run the Executable:

    On Linux or macOS:

    ./binary_heap_trees