170 likes | 271 Views
Anthony Kim, 2005 Computer Systems Research. A Study of Balanced Search Trees: Brainstorming a New Balanced Search Tree.
E N D
Anthony Kim, 2005 Computer Systems Research A Study of Balanced Search Trees:Brainstorming a New Balanced Search Tree
This project investigates three different balanced search trees for their advantages and disadvantages, thus ultimately their efficiency. Run time and memory space management are two main aspects under the study. Statistical analysis is provided to distinguish subtle differences if there is any. A new balanced search tree is suggested and compared with the four balanced search trees under study,. Balanced search trees are implemented in C++ extensively using pointers and structs. Abstract
A simple binary search tree has some disadvantages, specifically from its dependence on the incoming data, that significantly affects its tree structure hence its performance. (Ex. linear tree) An optimal search tree is one that tries to minimize its height given some data. (Ex. Red-black tree has 2lg(n+1) height max) Some of balanced search trees are red-black tree, AVL tree, weight-balanced tree, and B tree. Introduction
Simple vocabs: nodes, edges, children, parent, root Printing tree using recursion: pre-, in-, and post-order traversal Basic binary search tree functions: insertion, lookup, deletion (only first two apply in this project) Rotating functions: the key player in balancing (Left rotation and right rotation.) Background
Four properties The root of the tree is colored black. All paths from the root to the leaves agree on the number of black nodes. No path from the root to a leaf may contatin two consecutive nodes colored red. Every path from a node to a leaf (of the descendants) has the same number of black nodes Has height at most 2lg(n+1) Some Balanced Search (Red-black tree)
Weight balanced tree and height balanced tree are very similar. Weight balanced tree (Height balanced tree) has one property At each node, the difference between weight(height) of left subtree and weight(height) of right subtree is less than the threshold value. Supposedly yield height lg(n) at most Some Balanced Search Tree(Weight & height balanced search tree.)
Assumption on statistical data Give lower bound and upper bound of total data input, random behavior is assumed, meaning data points will be evenly distributed throughout the interval Multiple “crests” is assumed to be present in the interval. Each node will have a key (data number), an interval (with lower and upper bounds of its assigned interval) and weights of left subtree and right subtree. A New Balanced Search TreeMedian-weight-mix tree
Algorithm The weights of each subtree are calculated based on constants R and S R = the importance of focusing frequency heavy data points S = the importance of focusing frequency weak data points Left/right rotations to balanced R to S ratio A New Balanced Search TreeMedian-weight-mix tree
Testing Methodology • 14 Randomly generated test cases (test case size ranges 20 – 10,000) • 4 Real test scores of math competition etc. • Things I am looking for • Total Run Time • Average Time Retrieval • Height of Tree • Average Retrieval Depth
Result • Total run time and average retrieval time data did not make any sense. • Hard to time processes on fast computers • Red-black tree segmentation faulted for large test cases >500, so it provided no experimental data
Analysis • All balanced search trees show logarithmic characteristics for height and average retrieval depth as expected. (except red-black tree) • Height-balanced tree seems to perform the best among three working balanced search trees. • Median-weight-mix tree’s logarithmic line lies between height-balanced tree’s line and weight-balanced tree’s line.
Conclusion • The project experimentally showed that balanced binary search trees show logarithmic characteristics. • Median-weight-mix tree’s performance is an intermediate between height-balanced tree’s and weight-balanced tree’s. • More studies should be done on other balanced search trees or variants of search trees studied in this project