Practice mode Data Structures

What is the main purpose of a header (dummy) node in a linked list?

Correct answer B. To remove special cases for inserting or deleting at the front of the list

Explanation

A header node sits before the first real element and holds no user data, so every real node, including the first, has a predecessor. Insertion and deletion code can then treat all positions the same way without checking whether the head pointer itself must change. It may optionally store a count, but its key role is simplifying the boundary cases.

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.