Problem 3 A memory efficient implementation of a doublylinke

Problem 3: A memory efficient implementation of a doubly-linked list is the xorlist. In this case, instead of storing both a previous and next pointer, you store only the exclusive OR of these values. Please create a template class implementing an xorlist. Note that you will only be adding nodes to the head of the list. For the xorListNode, please include the following methods // Member functions const xorListNode *getNext( const xorListNode \"prev) const; const xorListNode *getPrev const xorListNode *next const; xorListNode insert( const T &value;); const T &getvalue;() const In C++, you cannot directly \"XOR\" two pointers, so to accomplish this you will need to use statements like the following templatectypename T> const xorListNodec T> ·xorListNodecT>::getNext( const xorListNodecT> *prev ) const return (xorlistNode) (unsigned int)1ink (unsigned int)prev); Please create a test program, insert a few values into the list, and then traverse the list, printing out the values contained in each node.

Solution

Here is the code for Xor linked list in C++ inswerting values, traversing and printing values in XOR linked list

To delete a node in the linked list, we need to stay one node ahead of the one you want to delete :

 Problem 3: A memory efficient implementation of a doubly-linked list is the xorlist. In this case, instead of storing both a previous and next pointer, you sto

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site