Examveda

Consider the following pseudocode of insertion in XOR list and write the approximate code snippet of it.
void xor-linked-list insert(struct node **head_ref, int value)
{
    node *new_node  = new (struct node);
    new_node->value = value;
    new_node->nodepointerxored = xor (*head_ref, NULL);
    if (*head_pointer == NULL)
    {
        printf("invalid");
    }
    else
    {
        let b,c,d are nodes and a is to be inserted at beginning,
        a address field must contain NULL xor b and b 
        address filed must be a xor c.
    }
    *head_pointer = new_node;
}

A.

node* next = XOR ((*head_ref)->npx,  NULL);
  (*head_ref)->npx = XOR (new_node, next);

B.

node* next = XOR ((*head_ref)->npx,  NULL);
  (*head_ref) = XOR (new_node, next);

C.

node* next = XOR ((*head_ref)->npx,  NULL);
  (*head_ref)->npx->npx = XOR (new_node, next);

D.

node* next = XOR ((*head_ref),  NULL);
  (*head_ref)->npx = XOR (new_node, next);

Answer: Option A


This Question Belongs to Data Structure >> Linked Lists In Data Structures

Join The Discussion

Related Questions on Linked Lists in Data Structures

What is a circular linked list?

A. A list where each node points to the next

B. A list where the last node points to the first node

C. A list where each node points to itself

D. A list where the nodes are in a circle