Project 1 -- Questions and Answers
An interested student inquires: > I'm having trouble implementing the XOR functionality. > I know I have to type-cast the pointers, but it won't compile. EK responds: Try something like this: first = (Node < Dtype > * ( (int) header ^ (int) first->xor_ptr ); ek
An interested student inquires: > > When implementing the doubly linked list using the xor pointer, are we > supposed to set the value of each node's pointer address and its xor > pointer address when the node is created? > EK responds: The address of the new node node is returned to you when you use the "new" operator to create it. You would then use this value to update the xor values of the previous and next nodes in the list. Note that one of these may be the header node. The new node's xor value will be calculated by xor-ing the address of the node that precedes it with the address of the node that follows it in the list. Again, not that one of these may be the header node. ek
An interested student inquires: > > > Since the xor value is the value from the next and previous nodes being > xored, what xor value are we supposed to assign to the header node and the > first node? > > EK responds: In an empty list, the first node should be null and the xor pointer should also be null. Once you start inserting nodes into the list, the xor pointer of the header node will be adjusted to reflect that. ek
An interested student inquires: > > I'm getting some strange errors: > 1) every time I do something like > new Node(elementToPush) > I get a "parse error before (" > 2) when I do > Node* temp = Header; > I get "use of class template `template < class DT > * Node < DT >' as expression" > I'm including < new > in my header file, including my header file in my cc file, and including "friend class DLL < DT >"; " in my node.h file. What am I doing wrong? > EK responds: Try: new Node < T > (elementToPush) instead of > new Node(elementToPush) and Node < T > * temp = Header; instead of: > Node* temp = Header; ek
An interested student inquires: > >... > EK responds:
An interested student inquires: > >... > EK responds:
An interested student inquires: > >... > EK responds:
An interested student inquires: > >... > EK responds:
An interested student inquires: > >... > EK responds:
An interested student inquires: > >... > EK responds:
An interested student inquires: > >... > EK responds:
An interested student inquires: > >... > EK responds: