I think all of these are the characteristics but please let me know if any are not.
What are the characteristics of doubly linked list's sentinels, header and trailer?
-The header and trailer sentinels mark the ends of the doubly linked list.
-The header sentinel's next pointer points to the first data node of the non-empty list.
-The trailer sentinel's next pointer points to the last data node of the non-empty list.
-In an empty list, the header sentinel's next pointer points to the trailer sentinel, and the trailer's prev pointer points to the header sentinel.
-The header sentinel's previous pointer and trailer sentinel's next pointer can be set to null.
Last edited on
Do you mean that you have something like:
1 2 3 4 5 6 7 8 9 10
|
struct Node {
Node * prev = nullptr;
Node * next = nullptr;
ValueType data;
};
class List {
Node header;
Node trailer;
};
|
What would happen if you had:
1 2 3 4
|
class List {
Node * header = nullptr;
Node * trailer = nullptr;
};
|
Last edited on
I think so, that was just the question.