Skip to content

ada-c17/Sorted-Array-to-BST

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sorted Array to Binary Search Tree

An exercise working with Binary Search Trees

Exercise

Given a sorted array of integers, arr, write a function to create a balanced Binary Search Tree from the contents of the array. Return the root of the Binary Search Tree.

Example:

arr = [5, 10, 15, 20, 25, 30, 35, 40, 45]

should result in a tree with the following root/height:

Balanced Binary Search Tree

Hint

Please note one is not required to implement a self-balancing Binary Search Tree in order to solve this exercise.

It is recommended to break the problem down recursively by first setting the root of the Binary Search Tree to the middle element of the array.

Getting Started

As usual with a python project, create a virtual environment:

python3 -m venv venv

Then activate the virtual environment

source venv/bin/activate

Then install the required packages.

pip install -r requirements.txt

About

An exercise working with Binary Search Trees

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 77.9%
  • Dockerfile 21.4%
  • Shell 0.7%