Results (
Indonesian) 1:
[Copy]Copied!
In Sections 1.4, 4.5, and 5.3, we discussed the binary search tree—one of the principal data structures for implementing dictionaries. It is a binary tree whose nodescontain elements of a set of orderable items, one element per node, so that all elements in the left subtree are smaller than the element in the subtree’s root, and allthe elements in the right subtree are greater than it. Note that this transformationfrom a set to a binary search tree is an example of the representation-change technique. What do we gain by such transformation compared to the straightforwardimplementation of a dictionary by, say, an array? We gain in the time efficiencyof searching, insertion, and deletion, which are all in(logn), but only in the average case. In the worst case, these operations are in(n)because the tree candegenerate into a severely unbalanced one with its height equal ton−1.Computer scientists have expended a lot of effort in trying to find a structurethat preserves the good properties of the classical binary search tree—principally,the logarithmic efficiency of the dictionary operations and having the set’s elements sorted—but avoids its worst-case degeneracy. They have come up with twoapproaches.The first approach is of the instance-simplification variety: an unbalancedbinary search tree is transformed into a balanced one. Because of this, suchtrees are called self-balancing. Specific implementations of this idea differby their definition of balance. AnAVL treerequires the difference betweenthe heights of the left and right subtrees of every node never exceed 1. Ared-black treetolerates the height of one subtree being twice as large as theother subtree of the same node. If an insertion or deletion of a new nodecreates a tree with a violated balance requirement, the tree is restructuredby one of a family of special transformations calledrotationsthat restore thebalance required. In this section, we will discuss only AVL trees. Informationabout other types of binary search trees that utilize the idea of rebalancingvia rotations, including red-black trees andsplay trees, can be found in thereferences [Cor09], [Sed02], and [Tar83].
Being translated, please wait..
