Search Tree
A search tree is a tree data structure used for locating specific Keys from within a collection of keys, and used as an implementation of a Set.
A search tree consists of a collection of Nodes, and each node contains an ordered collection of keys. For example, consider a search tree with integer keys:
To search if the key 64
is contained within the set:
- Start from the top node
(1, 31)
,64
is greater than31
so go right - In
(58, 101)
,64
is greater than58
but smaller than101
, so go down the pointer between58
and101
- In
(60, 64, 77)
, we find exact value for64
- Conclusion reached that key
64
is contained within the set
N-Way Search Tree
A N-way search tree is a search tree where:
- A node with
k
children must havek-1
number of keys. - Each node must have a maximum of
N
child nodes (i.e. each node must have a maximum ofN-1
keys)
The example above thus satisfies the requirement of being a 4-way search tree.