Binary search tree: Difference between revisions
Jump to navigation
Jump to search
(→Remark) |
|||
Line 25: | Line 25: | ||
== Remark == | == Remark == | ||
* Besides the methos of [[sorted sequences]], binary search trees have a private method [[Binary | * Besides the methos of [[Sorted sequence|sorted sequences]], binary search trees have a private method [[Binary Search Tree:Remove node]], which receives a pointer '''''p''''' to a binary search tree node and removes id (possibly by removeing another node and overwriting the key to be removed with the key of the other node. Prerequisite: <math> p.left \neq void</math> | ||
* There are variants on binary search trees, such as [http://en.wikipedia.org/wiki/AVL_tree AVL trees] and [http://en.wikipedia.org/wiki/Red_black_tree red-black-trees], for which the height of the tree is guaranteed to be in <math>O \log{n}</math> in these variants (because the additional operations in these methods are necessary to maintain logatihmic height are linear in the height of the tree as well=. | * There are variants on binary search trees, such as [http://en.wikipedia.org/wiki/AVL_tree AVL trees] and [http://en.wikipedia.org/wiki/Red_black_tree red-black-trees], for which the height of the tree is guaranteed to be in <math>O \log{n}</math> in these variants (because the additional operations in these methods are necessary to maintain logatihmic height are linear in the height of the tree as well=. | ||
* For further information, see section "Binary search tree" of page [[Directed tree]]. | * For further information, see section "Binary search tree" of page [[Directed tree]]. |
Revision as of 11:41, 26 September 2014
General Information
Abstract Data Structure:
Implementation Invariant:
- There is a tree item type with three components:
- key is of generic type [math]\displaystyle{ \kappa }[/math]
- left and right of type "pointer to tree item of type [math]\displaystyle{ \kappa }[/math]"
- An object of the binary search tree type contains a pointer root of type "pointer to tree item of type [math]\displaystyle{ \kappa }[/math]"
- The pointer root points to a well-formed binary search tree. In accordance with the definition of directed trees, "well-formed" means that, for any node, there is exactly one path from the root to that node.
Remark
- Besides the methos of sorted sequences, binary search trees have a private method Binary Search Tree:Remove node, which receives a pointer p to a binary search tree node and removes id (possibly by removeing another node and overwriting the key to be removed with the key of the other node. Prerequisite: [math]\displaystyle{ p.left \neq void }[/math]
- There are variants on binary search trees, such as AVL trees and red-black-trees, for which the height of the tree is guaranteed to be in [math]\displaystyle{ O \log{n} }[/math] in these variants (because the additional operations in these methods are necessary to maintain logatihmic height are linear in the height of the tree as well=.
- For further information, see section "Binary search tree" of page Directed tree.