Does the Head(start) pointer of Doubly Linked list points previously to the tail(last) node

data structureslinked list

I have one question in my mind that in case of circular doubly linked list the head pointer of the doubly linked list also logically point to the next pointer of the tail node of the linked list and tail's next pointer also point to the previous pointer of head.

Please Answer me this question I am a bit confused.

Best Answer

It depends.

Is it a circular or linear list?

If it's a circular list then there is no "head" or "tail" as each element's next and prev pointers will be set. You can start traversing the list anywhere and have to remember where you started so you know when to stop.

If it's a linear list then the prev pointer of the head element will be null and the next pointer of the tail element will be null. You use this information to know when to stop.