I have been trying to implement XOR linked list and its operations but I have not been able to do it properly.
Is it possible to implement it in C since XOR link list involves operations on addresses?
I would be very thankful if some actual working code is given.
That’s an interesting idea that I have not seen before. With today’s fairly abundant memory, it seems like a lot of complexity for little gain (although not all platforms are flush with memory). Edit While doing my real work, my mind kept drifting back to it, so I added the function to create the new node and put it on the given end. Prettier now. It’s rather cool that both the addnode and traverse functions are symmetrical. Neither needs to know the direction. Just give it one end of the list and they operate correctly.
And based on Darron’s comment (thanks), I changed the int to
intptr_tfor portability.