Considerations for single-chain table Processing

Source: Internet
Author: User

The node Structure of a single-chain table is generally as follows:

Struct node {int val; node * Next ;};

 

Pay attention to the following when dealing with the basic operations of a single linked list:
1. Remember the header Node
Each operation on a single-chain table must start from the first node. If the header node in the function changes, such as inserting a node before the header node, deleting the header node, and reversing the linked list, you must update the header node. Otherwise, the linked list will be lost.

2. Check the end of the linked list continuously when you use a traversal link.

3. During insertion and deletion, you need to find the node before the insertion point or Deletion Point. Note that you must update the header node before inserting or deleting the header node.

4. fast and slow pointers are sometimes powerful tools.

 

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.