Search code examples
data-structurespseudocodecircular-list

Linked Lists and Sentinal node


So i have been asked in my homework to merge-sort 2 different sorted circular linked lists without useing a sentinal node allso the lists can be empty, my questsion is what is a sentinal node in the first place?


Solution

  • a sentinal node is a node that contains no real data - it's just there for the convenience of the implementation.

    Thus a list with 4 real elements might have one or more extra nodes, making a total of 5 or 6 nodes.

    Those extra nodes might be place holders (e.g. marking where you started the merge), pseudo-nodes indicating the head of the list, or anything else the algorithm designer can think up.