How exactly does a XOR Linked list work?

前端 未结 5 2100
悲哀的现实
悲哀的现实 2020-12-16 10:15

The following link explains it.
The implementation is said to work by storing the XOR of the previous and next address(say nxp), instead of storing both(previous and

5条回答
  •  -上瘾入骨i
    2020-12-16 10:52

    But isnt this practically using the same space as having previous and next pointers?

    No - it uses about half the space, as the size of the result of XOR-ing the "prev" and "next" is equal to the size of the larger of the two.

提交回复
热议问题