Linear table Lookup algorithm
Sequential Lookup
Binary lookup (linear table must be already sorted)
1 /**binary Find2 * @paramobj3 * @paramvalue4 */5 Public Static voidHalfsort (int[] obj,intvalue) {6 intLen=obj.length;//gets the length of the array7 intMin=0;8 intMax=len-2;9 while(min<=max) {Ten intMiddle= (Min+max)/2;//gets the subscript for the middle element of an array One if(obj[middle]==value) { ASystem.out.println ("Zhaodao"); - return ; - } the Else if(obj[middle]>value) { -Max=middle-1; } - Else{ -Min=middle+1; + } -System.out.println ("Zhaodao failed"); +}
binary Find
Binary search tree ()
1 if its left subtree is not empty, the values of all nodes on the left subtree are smaller than the value of the root node
2 If the right subtree is not empty, the values of all nodes on the right subtree are greater than the value of the root node
Around 3 The subtree itself is a binary search tree
The middle sequence traversal sequence obtained by the middle sequence traversal binary search tree is an ascending sequence (left and right)
Finding data structures and algorithms