19--the replication of complex linked lists.

Source: Internet
Author: User
/* title:    replication of complex linked lists. struct complexlistnode{    int m_vlaue;    Complexlistnode *m_next;    Complexlistnode *m_psibling;} , M_next, connects to the next node, m_psibling links to other nodes. This makes it difficult to replicate nodes, and it is not possible to solve them all at once. Strategy:    The first method: first        Copy the linked list, let M_pnext connect the nodes together. The second round is copying another pointer, the complexity of O (n*n);    The second method:        first copy the linked list, then space for time, with an O (n) long hash table to store the data, order to save the corresponding pointer.        Save the M_psibling pointer, and then the second change in the loop is possible.    the Third Kind:        the algorithm that does not join the auxiliary space.        (1): In order to create a linked list one, and connected to the previous node        for example: Start the list for ABCDEFG, after the creation of the AABBCCDDEEFFGG.        (2): Here for example, if a points to C. So it must be a point C. So, a points to the next of C.        after traversal, point to the next node where the node points to the node.        (3): The Separation chain list, in        fact, is the odd-even analysis! Starting from 0, the even number is the academician linked list, odd is the clone linked list. */

19--the replication of complex linked lists.

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.