11.07.2015 Views

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

13Advanced Tree <strong>Structures</strong>This chapter introduces several tree structures designed for use in specialized applic<strong>at</strong>ions.The trie of Section 13.1 is commonly used to store <strong>and</strong> retrieve strings.It also serves to illustr<strong>at</strong>e the concept of a key space decomposition. The AVLtree <strong>and</strong> splay tree of Section 13.2 are variants on the BST. They are examples ofself-balancing search trees <strong>and</strong> have guaranteed good performance regardless of theinsertion order for records. An introduction to several sp<strong>at</strong>ial d<strong>at</strong>a structures usedto organize point d<strong>at</strong>a by xy-coordin<strong>at</strong>es is presented in Section 13.3.Descriptions of the fundamental oper<strong>at</strong>ions are given for each d<strong>at</strong>a structure.One purpose for this chapter is to provide opportunities for class programmingprojects, so detailed implement<strong>at</strong>ions are left to the reader.13.1 TriesRecall th<strong>at</strong> the shape of a BST is determined by the order in which its d<strong>at</strong>a recordsare inserted. One permut<strong>at</strong>ion of the records might yield a balanced tree whileanother might yield an unbalanced tree, with the extreme case becoming the shapeof a linked list. The reason is th<strong>at</strong> the value of the key stored in the root node splitsthe key range into two parts: those key values less than the root’s key value, <strong>and</strong>those key values gre<strong>at</strong>er than the root’s key value. Depending on the rel<strong>at</strong>ionshipbetween the root node’s key value <strong>and</strong> the distribution of the key values for theother records in the the tree, the resulting BST might be balanced or unbalanced.Thus, the BST is an example of a d<strong>at</strong>a structure whose organiz<strong>at</strong>ion is based on anobject space decomposition, so called because the decomposition of the key rangeis driven by the objects (i.e., the key values of the d<strong>at</strong>a records) stored in the tree.The altern<strong>at</strong>ive to object space decomposition is to predefine the splitting positionwithin the key range for each node in the tree. In other words, the root could bepredefined to split the key range into two equal halves, regardless of the particularvalues or order of insertion for the d<strong>at</strong>a records. Those records with keys in thelower half of the key range will be stored in the left subtree, while those records429

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!