Skip to content

wonderingdev/binary-tree-country-management_data-structure

 
 

Repository files navigation

## Binary Tree management

A C program that manages country information using a binary tree data structure. It allows insertion, in-order display, height and depth calculations, and more.

Features

  • Insert country data (name, capital, area, etc.)
  • Calculate tree depth
  • Calculate node depth (based on number of cities)
  • Calculate node depth (based on number of cities)
  • Calculate node height (based on area)
  • Display all tree leaves
  • Free memory

Screen Captures

In order to check if the program works correctly, I introduced information about 3 countries image

Results based on menu option

  1. The result of choosing the first option from the meniu - Calculate tree depth image

  2. The result of choosing the second option of the menu - Search for a node by key (foundation year) Screenshot 2025-05-06 194447

  3. For the same contries entered above, we have the result of the third option of the menu - Calculate node depth (based on number of cities)

Screenshot 2025-05-06 194750

  1. The result of the fourth option of the menu - Calculate node height (based on area) image

  2. The result of the fifth option of the menu - Display all tree leaves. image

Explanation of the result: The binary tree is built based on the area. The first node inserted is Moldova, which becomes the root. The second node is Romania. Its area is compared with Moldova’s (238397 > 33843), so it is inserted to the right of the root. The third node is Germany. Its area is compared with Moldova’s (357022 > 33843), so it goes to the right of the root, where Romania is already placed. Then, Germany’s area is compared with Romania’s (357022 > 238397), so it is inserted to the right of Romania.

The tree looks like this:

   Moldova
        \
        Romania
              \
              Germania

Language

  • C

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C 88.7%
  • C++ 11.3%