2009/07/19

Balanced Tree

AVL Balanced tree program written in C. Refer to http://en.wikipedia.org/wiki/AVL_tree. This program can display a tree structure as below. It also have a cursor which can be moved by numeric key (1-9). Cursor node is also highlight displayed :)

==================== Balance Tree (6)====================
[13](-1)----[38](-1)----[57](+1)----[90](+0)----[99](+0)
  |           |           |           +----[86](+0)
  |           |           +----[44](-1)----[54](+1)
  |           |                       |           +----[50](+0)
  |           |                       +----[39](+0)
  |           +----[23](+0)----[29](+0)----[35](+0)
  |                       |           +----[26](+0)
  |                       +----[19](+1)
  |                                   +----[14](+0)
  +----[10](+1)----[12](+1)
              |           +----[11](+0)
              +----[06](-1)----[08](+0)----[09](+0)
                          |           +----[07](+0)
                          +----[04](+0)
Cursor [29]
========== TREE OPERATION MENU ==========================
[7] Root     [8] Up      [9] Largest  [ ]      
[4] Up/Leftt [5] Left    [6] Right    [ ]      
[1] Smallest [2] LeftMost[3] RightMost[ ]      
        [0] INSERT  [.] DELETE   [q] QUIT 
==> Your Choice :


沒有留言: