Science Fair Projects Ideas - Xor linked list

All Science Fair Projects

      

Science Fair Project Encyclopedia for Schools!

  Search    Browse    Forum  Coach    Links    Editor    Help    Tell-a-Friend    Encyclopedia    Dictionary     

Science Fair Project Encyclopedia

For information on any area of science that interests you,
enter a keyword (eg. scientific method, molecule, cloud, carbohydrate etc.).
Or else, you can start by choosing any of the categories below.

Xor linked list

Xor linked lists are a curious use of the bitwise exclusive disjunction (XOR) operation to decrease storage for doubly-linked lists. An ordinary doubly-linked list stores addresses to the previous and next list items, requiring two address fields in each list node:

 ... A-1       A         B         C         C+1 ...
          <–  prev  <–  prev  <–  prev  <–
          –>  next  –>  next  –>  next  –>

An Xor linked list will compress the same information into one address field by storing the bitwise XOR of the address for previous and the address for next in one field:

 ... A-1           A             B             C           C+1 ...
          –>  A-1 XOR B  <–>  A XOR C  <–>  B XOR C+1  <–

When you traverse the list from left to right: supposing you are at B, you can take the address of the previous item, A, and XOR it with the value in the XOR field. You will then have the address for C and you can continue traversing the list. The same pattern applies in the other direction.

To start traversing the list in either direction from some point, you need the address of two consecutive items, not just one. If the addresses of the two consecutive items are reversed, you will end up traversing the list in the opposite direction.

Most authorities no longer recommend using this particular trick for the following reasons:

  • general-purpose debugging tools cannot follow the XOR chain, making debugging more difficult;
  • except in some embedded systems, RAM storage has become cheap, making the trick less necessary; and
  • conservative garbage collection schemes do not work with data structures that do not contain literal pointers.

A more practical and effective approach for decreasing the storage used by linked lists are unrolled linked lists.

See also

09-23-2007 01:00:40
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details
Science kits, science lessons, science toys, maths toys, hobby kits, science games and books - these are some of many products that can help give your kid an edge in their science fair projects, and develop a tremendous interest in the study of science. When shopping for a science kit or other supplies, make sure that you carefully review the features and quality of the products. Compare prices by going to several online stores. Read product reviews online or refer to magazines.

Start by looking for your science kit review or science toy review. Compare prices but remember, Price $ is not everything. Quality does matter.
Science Fair Coach
What do science fair judges look out for?
ScienceHound
Science Fair Projects for students of all ages
All Science Fair Projects.com Site
All Science Fair Projects Homepage
Search | Browse | Links | From-our-Editor | Books | Help | Contact | Privacy | Disclaimer | Copyright Notice