Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Binary Tree Algorithms

Contents:

Overview

This project features a GUI-based application showcasing various Binary Tree algorithms. Users can visually interact with the tree structure and execute the following algorithms:

  • Single Traversal: Efficiently traverses the tree in one go to achieve specific goals.
  • Stack-Based Traversal: Uses a stack to simulate recursive traversal.
  • Distance Between Nodes: Computes the distance between two nodes or a node and the root.
  • Sorted Array to Balanced BST: Converts a sorted array into a balanced Binary Search Tree.
  • Diameter of a Binary Tree: Calculates the longest path between any two nodes in the tree.
  • Equal Tree Partition: Determines if the tree can be divided into two equal sum partitions.
  • Flatten Binary Tree: Converts the tree into a flattened linked list-like structure.
  • Invert Binary Tree: Produces a mirror image of the binary tree.
  • Find Lowest Common Ancestor (LCA): Includes two different approaches to locate the LCA of two nodes.

Note

The program allows tree input via file. An example input file is provided here

Screenshots

draw tree

flatten BT

invert BT

Setup and Usage

Prerequisites

  • A C++ compiler that supports C++11 or higher.
  • Qt5 installed on your system.

Usage

To build:

make

To run:

cd bin && ./binary_tree_gui

To clean:

make clean