What is a doubly linked list?
If someone could provide some C++ code to help explain then that would be much appreciated.
What is a doubly linked list?
If someone could provide some C++ code to help explain then that would be much appreciated.
struct node
{
node * next;
int val;
};
node * head;
void append_value(int x)
{
node n = { 0, x };
head->next = &n * 2; // doubly linked.
}
Turn that in and I guarantee you'll get the grade you deserve.
Basically, instead of having one pointer to the next node like a node in a singly-linked list would, each node in the doubly linked list has two pointers - one to the previous node and one to the next node. The first node in the list would point to a previous null pointer and the last node would point to a next null pointer.
http://www.daniweb.com/code/snippet216960.html
Link from there gives a basic code example