Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Search tree
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Types of trees== [[File:Binary search tree.svg|thumb|alt=Binary search tree|Binary search tree]] ===Binary search tree=== {{Main|Binary search tree}} A Binary Search Tree is a node-based data structure where each node contains a key and two subtrees, the left and right. For all nodes, the left subtree's key must be less than the node's key, and the right subtree's key must be greater than the node's key. These subtrees must all qualify as binary search trees. The worst-case [[time complexity]] for searching a binary search tree is the [[Tree (data structure)#Terminology used in trees|height of the tree]], which can be as small as O(log n) for a tree with n elements. ===B-tree=== {{Main|B-tree}} B-trees are generalizations of binary search trees in that they can have a variable number of subtrees at each node. While child-nodes have a pre-defined range, they will not necessarily be filled with data, meaning B-trees can potentially waste some space. The advantage is that B-trees do not need to be re-balanced as frequently as other [[Self-balancing binary search tree|self-balancing trees]]. Due to the variable range of their node length, B-trees are optimized for systems that read large blocks of data, they are also commonly used in databases. The time complexity for searching a B-tree is O(log n). ===(a,b)-tree=== {{Main|(a,b)-tree}} An (a,b)-tree is a search tree where all of its leaves are the same depth. Each node has at least '''a''' children and at most '''b''' children, while the root has at least 2 children and at most '''b''' children. '''a''' and '''b''' can be decided with the following formula:<ref>Toal, Ray. [http://cs.lmu.edu/~ray/notes/abtrees/ "(a,b) Trees"]</ref> <math>2 \le a \le \frac{(b+1)}{2}</math> The time complexity for searching an (a,b)-tree is O(log n). ===Ternary search tree=== {{Main|Ternary search tree}} A ternary search tree is a type of [[Tree (data structure)|tree]] that can have 3 nodes: a low child, an equal child, and a high child. Each node stores a single character and the tree itself is ordered the same way a binary search tree is, with the exception of a possible third node. Searching a ternary search tree involves passing in a [[string (computer science)|string]] to test whether any path contains it. The time complexity for searching a balanced ternary search tree is O(log n).
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)