Skip to content

JuliaCollections/BinaryTrees.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BinaryTrees.jl

Build Status Coverage

Overview

This package provides a collection of binary trees implemented in Julia.

Currently, it includes the following binary trees:

  • AVL Tree: A self-balancing binary search tree.

Installation

To install BinaryTrees.jl, use the Julia's package manager:

] add https://github.com/eliascarv/BinaryTrees.jl

AVL Tree

An AVL tree is a binary search tree that keeps itself balanced to ensure efficient search, insertion, and deletion operations.

Example Usage

using BinaryTrees

tree = AVLTree{Int,Float64}()

# insert nodes into the tree
BinaryTrees.insert!(tree, 2, 2.2) # root node
BinaryTrees.insert!(tree, 1, 1.1) # left node
BinaryTrees.insert!(tree, 3, 3.3) # right node

# update the value of the node
BinaryTrees.insert!(tree, 2, 2.4)

# search for nodes using their keys
BinaryTrees.search(tree, 2) # root node
BinaryTrees.search(tree, 1) # left node
BinaryTrees.search(tree, 3) # right node

# delete nodes from the tree
BinaryTrees.delete!(tree, 1)
BinaryTrees.delete!(tree, 3)

# tree that only has keys
tree = AVLTree{Int}()
BinaryTrees.insert!(tree, 2) # root node
BinaryTrees.insert!(tree, 1) # left node
BinaryTrees.insert!(tree, 3) # right node