Steps to create DLL:
- For, after creating the first node, make its pointer point to NULL.
- Now, create a next node and then make it point to the predecessor node.
- The pointer of the predecessor node is XOR with the current node. i.e. pred->pointer= pred->pointer ^ current_node
- Jump to Step 2 to add more elements
Displaying the DLL
- Check the list to be displayed is empty. If so, return.
- Use two additional pointers prev and temp. Initialize prev to NULL.
- Now, save list to temp variable.
- Find new value of list by: list=list->ptr ^ prev.
- Set prev=temp.
- Jump to Step 3 until list become NULL
Read full article from Electronics and Computer Engineering: Doubly Linked List using Single Pointer
No comments:
Post a Comment