# Xor Linked List | Data Structure MCQs

1.

Given 10,8,6,7,9
swap the above numbers such that finally you got 6,7,8,9,10
so now reverse 10
9,7,6,8,10
now reverse 9
8,6,7,9,10
7,6,8,9,10
6,7,8,9,10
at this point 6 is ahead so no more reversing can be done so stop.
To implement above algorithm which datastructure is better and why ?

A.) linked list. because we can swap elements easily
B.) arrays. because we can swap elements easily
C.) xor linked list. because there is no overhead of pointers and so memory is saved
D.) doubly linked list. because you can traverse back and forth

Answer: Option 'C'

As in the option, you will store xored value of pointer rather than two pointers.

2.

What does a xor linked list have?

A.) every node stores the XOR of addresses of previous and next nodes
B.) actuall memory address of next node
C.) every node stores the XOR of addresses of previous and next two nodes
D.) every node stores xor 0 and the current node address

Answer: Option 'A'

Every node stores the XOR of addresses.

3.

What does first and last nodes of a xor linked lists contain ? (let address of first and last be A and B)

A.) NULL xor A and B xor NULL
B.) NULL and NULL
C.) A and B
D.) NULL xor A and B

Answer: Option 'A'

NULL xor A and B xor NULL

4.

What are the important properties of xor lists

A.) X⊕X = 0
B.) X⊕0 = X
C.) (X⊕Y)⊕Z = X⊕(Y⊕Z)
D.) All of the mentioned

Answer: Option 'D'

All of the mentioned
The above are properties of xor lists.

5.

Which of the following statements are true ?
i) practical application of XOR linked lists are in environments with limited space requirements, such as embedded devices.
ii)xor lists are not suitable because most garbage collectors will fail to work properly with classes or structures that don’t contain literal pointers
iii)in order to calculate the address of the next node you need to remember the address of the previous node
iv)xor lists are much efficient than single, doubly linked lists and arrays

A.) i,ii,iii,iv
B.) i,ii,iii
C.) i,ii
D.) i

Answer: Option 'B'

Xor lists requires same time for most of the operations as arrays would require.

<