Question discussion

Consider the given memory representation of the singly linked list where start points to the address of first node of the linked list, whic…

359049Medium DSSSB TGT Computer Science 0 replies 0 views
0
Consider the given memory representation of the singly linked list where start points to the address of first node of the linked list, which is memory location 0.

Memory representation of the singly linked list

Memory locationItem valuePointer to the next element
0A4
1E2
2BNULL
3
4C1

If a new node whose data value is X is inserted after the node whose data value is E in any free location available in the memory, then what will the memory representation be after inserting the new node?

  • A

    Memory representation of the linked list after inserting node X

    Memory locationItem valuePointer to the next element
    0A4
    1E2
    2BNULL
    3X1
    4C3
  • B

    Memory representation of the linked list after inserting node X

    Memory locationItem valuePointer to the next element
    0A4
    1E3
    2BNULL
    3X2
    4C1
  • C

    Memory representation of the linked list after inserting node X

    Memory locationItem valuePointer to the next element
    0A3
    1E2
    2BNULL
    3X4
    4C1
  • D

    Memory representation of the linked list after inserting node X

    Memory locationItem valuePointer to the next element
    0A4
    1E2
    2B3
    3XNULL
    4C1
Correct answer: B

Explanation

X is stored at free location 3. E (location 1) must now point to 3 and X must point to what E pointed to earlier (location 2). So the entries are E → 3 and X → 2.

Discussion 0

Nobody has replied yet. Start the discussion!