1. Basic concepts of linked lists
- 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;
- 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
- When the list is empty or the length is 1 o'clock, special handling;
- 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
- 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)
- Binary search can also be used in unordered sequences;
Data structures and Algorithms (4)-----> linked list, binary search