Exclusive or linked list

Source: Internet
Author: User
Structure of an exclusive or linked list

This is a data structure. The bitwise OR operation of a computer is used to reduce the storage needs of two-way linked lists.

...  A       B         C         D         E  ...          –>  next –>  next  –>  next  –>          <–  prev <–  prev  <–  prev  <–
As shown in the preceding figure, each node has two pointers pointing to the frontend and successor of the node respectively.
The XOR linked list is shown below:
 ...  A        B         C         D         E  ...         <–>  A⊕C  <->  B⊕D  <->  C⊕E  <->
The exclusive or exclusive address in a pointer. For example, B stores the value of a branch C.
In this way, we need to know how to start from the beginning.Two nodes(Unlike normal linked lists, only one is needed ).
For example, if we know node A and Node B, we can use the address of node A and A between C in Node B to get a C from a between C. This isForward Traversal
Reverse TraversalFor example, if you know nodes E and D, you can use the address of E and the C branch e operation in D to obtain c Branch E
 

However, this structure is used for research and usage.We do not recommend this function for the following reasons::

  1. Common debug tools do not support XOR linked lists.
  2. Reduces memory overhead by increasing Code complexity and increases maintenance costs.
  3. The normal garbage collection mechanism does not work properly.
  4. Although most languages Support XOR, some languages do not support XOR operations.
  5. The pointer is meaningless when it is not in a traversal table. For example, another data structure also contains pointers in the linked list.
  6. In order to calculate the address of the next pointer, you must remember the address of the previous node.
  7. XOR linked lists cannot provide functions provided by two-way linked lists. For example, if only one node is known, the node is removed from the linked list or inserted to the end of the node when only one node is known.

As resources become cheaper and memory grows, memory is no longer an important factor except for some embedded systems.

 

Deformation of the structure

Addition linked list: the sum of the put addresses

 ...  A        B         C         D         E  ...         <–>  A+C  <->  B+D  <->  C+E  <->
Subtraction linked list: the difference of the placed address
...  A        B         C         D         E  ...         <–>  C-A  <->  D-B  <->  E-C  <->
The difference is that the forward and reverse operations need to be performed differently.

 

Http://en.wikipedia.org/wiki/XOR_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.