AVL Tree

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Core Language > Data Structures >

AVL Tree

 

Description

 

AVL Tree implements a data structure container able to store/retrieve/delete a Key/Value relationship.

 

An AVL Tree is a self-balancing binary search tree. In an AVL Tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is done to restore this property.

 

An AVL Tree containers has the following characteristics:

AVL Self-Balanced Binary Tree

one-to-one Key/Value relationship

Values stored/retrieved/removed using unique lookup Key

Keys must be unique

no limit on Key length

Value replaced if Key exist

Tree always stays in Key order

Tree may be traversed forward/backward in Key order

Tree is self-balanced to maintain shortest average path to each Key

 

 

Additional information about AVL Tree

 

Use Wikipedia as source of information: https://en.wikipedia.org/wiki/AVL_tree

 

 

How to use in thinBasic

 

As a minimum, the following are the step required to use an an AVL Tree:

1.use Tree_New to create a new AVL Tree

2.use Tree_Set to add/change key/value pairs

3.use Tree_Get to retrieve key/value pairs

4.use Tree_Free to remove the entire AVL Tree and all associated key/value pairs