Cyclic and bidirectional linked lists

Source: Internet
Author: User

Cyclic linked list: by pointing a pointer to a terminal node in a single linked list to a header node by a null pointer, the whole single-linked list will travel in a ring. This single-linked list connected to the beginning and end is called a single-cycle linked list, cyclic linked list for short.

The circular linked list solves the problem of finding any node in a single linked list from any node in a single linked list.



Two-way linked list: In each node of a single-chain table, set a pointer field pointing to its precursor node. Therefore, each node in the two-way linked list has two pointer fields, one pointing to direct successor, and the other pointing to direct precursor.


Insert a two-way linked list:


Idea: the sequence of insert operations is to first determine the precursor and successor of the node s to be inserted, then the precursor of the successor node, and finally the successor of the precursor node.



Two-way linked list deletion:


The sequence problem cannot be messy. Suppose a case like this: a family of three shopping shops, Dad in the middle, dad holding his mother in the left and holding the child in the right hand. At this time, the child suddenly had to eat ice cream, and his father had no way to leave to buy it. However, if my father does not feel at ease and his mother does not hold the child's hand in time, she is most worried about the child. Therefore, before leaving, she should put the child's hand in her mother's hand first, then hold the mother's hand to the child. O (distinct _ distinct) O ~

Linked List summary:



Single-chain table, static linked list, cyclic linked list, and two-way linked list.

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.