Practice mode Data Structures

How many pointers must be changed to insert a new node between two existing nodes of a doubly linked list?

Correct answer A. 4

Explanation

The new node needs its prev and next set to its neighbours (two changes), and the neighbours must point to it: the left node's next and the right node's prev (two more). That makes four pointer assignments. In a singly linked list the same insertion takes only two, since nodes have no backward link to maintain.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.