logo

BST traversals

BST traversals

Second Practical Work in Algorithmics and Dynamic Data Structures

Overview

This project, developed in collaboration with Ait Ahmed Tarek, supervised by Pr D.E Zegour, focuses on implementing and animating two types of traversals for a Binary Search Tree (BST) using the C programming language. Additionally, we have utilized the Z language, which is specific to our higher school (ESI), to complement the algorithmic aspect of this project.

The project includes:
1. Branch-by-branch traversal (Bottom to Top, Left to Right and its Right to Left variant).
2. Leaf-by-leaf traversal (Left to Right and its Right to Left variant).
3. Random tree generation.
4. User interaction for manual or random tree creation.
5. Animation of the traversals.

The main program is coded in C and can be run in a C IDE. The algorithm is achieved through the use of Z language and can be accessed and run in its respective IDE [KHAWARIZM](https://zegour.esi.dz/Developpement/Seriez/khawarizm_ii_afe.htm).

Features

1. Traversals

Branch-by-Branch Traversal
- Bottom to Top, Left to Right (BB_LR)**: This traversal explores the tree from the bottom-most branches, starting from the leftmost branch and moving to the right.
- Bottom to Top, Right to Left (BB_RL)**: This traversal explores the tree from the bottom-most branches, starting from the rightmost branch and moving to the left.

Leaf-by-Leaf Traversal
- Left to Right (LL_LR)**: This traversal explores only the leaf nodes, starting from the leftmost leaf and moving to the right.
- Right to Left (LL_RL)**: This traversal explores only the leaf nodes, starting from the rightmost leaf and moving to the left.

2. Random Tree Generation


The program can generate a random BST with a specified number of nodes. This feature is useful for testing the traversal algorithms on various tree structures.

3. Manual Tree Creation
Users can manually input the values to create their own BST. This allows for customized tree structures to test specific scenarios.

4. Animation
The traversals can be animated to visually demonstrate how the tree is traversed. This helps in understanding the traversal process better.

Installation and Usage

Prerequisites


- A C compiler (e.g., GCC).
- An IDE for C programming (e.g., Code::Blocks, Visual Studio).
- An IDE for the Z language (KHAWARIZM, specific to ESI).