Finding data structures and algorithms

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.