Types of searching 2.1 Binary search tree
In computer science, a binary search tree (BST) is a node based binary tree data structure which has the following properties: * The left subtree of a node contains only nodes with keys less than the node 's key. * The right subtree of a node contains only nodes with keys greater than the node 's key. * Both the left and right subtrees must also be binary search trees. From the above properties it naturally follows that: * Each node (item in the tree) has a distinct key.
Generally, the information represented by each node is a record rather than a single data element. However, for sequencing purposes, nodes are compared according to their keys rather than any part of their their associated records.
The major advantage of binary search trees over other data structures is that the related sorting algorithms and search algorithms such as in-order traversal can be very efficient.
Binary search trees are a fundamental data structure used to construct more abstract data structures such as sets, multisets, and associative arrays.
A binary search tree of size 9 and depth 3, with root 8 and leaves 1, 4, 7 and 13
-------------------------------------------------
-------------------------------------------------
1.2 Linear and sequential search
In computer science, linear search or sequential search is a method for finding a particular value in a list, that consists of checking every one of its elements, one at a time and in sequence, until the desired one is found.
Linear search is the simplest search algorithm; it is a special case of brute-force search. Its worst case cost is proportional to the number of elements in the list; and so is its expected cost, if all list elements are equally likely to be searched for. Therefore, if the list has more than a few elements, other methods (such as binary search or hashing) will be faster,
References: * ^ a b Donald Knuth (1997). The Art of Computer Programming. 3: Sorting and Searching (3rd ed.). Addison-Wesley. pp. 396–408. ISBN 0-201-89685-0. * ^ Gilberg, R.; Forouzan, B. (2001), "8", Data Structures: A Pseudocode Approach With C++, Pacific Grove, CA: Brooks/Cole, p. 339, ISBN 0-534-95216-X * ^ Heger, Dominique A * ^ A. Gibbons and W. Rytter, "Efficient Parallel Algorithms". Cambridge University Press, 1988. * ^ H. Casanova et al, "Parallel Algorithms". Chapman & Hall, 2008.