Data structures and Algorithms (4)-----> linked list, binary search

Source: Internet
Author: User

1. Basic concepts of linked lists
    1. Linked lists and arrays are a linear structure;
      • The array is a contiguous storage space;
      • The list space is not necessarily guaranteed to be continuous, and is temporarily allocated;
    2. Categories of linked lists
      • By direction:
        • Single linked list: Each node can only point to the next node through the next pointer;
        • Doubly linked list: In addition to the next pointer, you can also use the previous pointer, pointing to the previous node;
      • Press with no ring:
        • Ordinary linked list
        • A circular list (a linked list of the first and last elements, the next pointer to the first element, and the previous pointer to the last element for the doubly linked list)
2. Single-linked list rollover operation
    1. When the list is empty or the length is 1 o'clock, special handling;
    2. Other single-linked lists are used in the following ways:
      • Let's say that the part with the head that has been flipped in front is heads, and the current node is now
        • Point to the head of the now node's next pointer;
        • Set the now node to the head of the new rollover completion node header now;
        • Point to head now, and so on, the next pointer to the previous node of the now node.
3. Two points search common scenes
    1. Finding a number in an ordered sequence;
      • For example, given an array of arr, determine if the integer m is in arr (Train of thought: Determine the size of the mid-to-m relationship between Arr, if M>mid, then the left portion of mid is less than M (because ordered), the same method, Select Mid2 again for the elements between mid and right half to do the same search! Each search range is halved, and if no m is found in the last search of 0, M is not in the ARR array! return false)
    2. Binary search can also be used in unordered sequences;

Data structures and Algorithms (4)-----> linked list, binary search

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.