Hey guys just wondering if somebody could explain a simple example of doubly linked lists. I know that each node contains a prev next pointer but how does it look when its all coded. I checked on various websites i cant really find much that makes sense. Even if its a simple traversing doubly linked list ?

thanks

What isn't there to understand ? I mean, traversing is the exact same thing as traversing a single linked list, you just read the next pointer until you reach NULL. The only difference is that you can traverse it in two directions, using not only the next but also the previous pointer. This allows you to read the element just before another element in O(1) instead of O(x-1) where x is the position of the element in the list.

3. What does the o stand for sorry

4. It's a notation for the algorithmic complexity, also called Big O or Asymptotic Notation.

What I wanted to say is that if you're at element X in a single linked list and you want to access the element X-1, you need to start at the head and iterate all the way through the list until you are at element X-1. In a double linked list, you simply follow the "previous" pointer, so you only need one operation.

5. I digged up my first year folder, and i got this example

Code:
```#include <stdio.h>

struct node
{
struct node *prev;
int data;
struct node *next;
};

void insertNode( struct node **, int );
void DisplayNodes( struct node *, int );
struct node * CreateNode( );

int main()
{
int i;
int Toggle = 1;

for( i=0;i<10;i++ )
DisplayNodes( head, (Toggle ^= 3) );

getchar();
return 0;
}

struct node * createnode()
{
return malloc(sizeof(struct node));
}

void insertNode( struct node **head, int data)
{
struct node *tempnode, *tempnode1;

{
}
else
{

while( empnode->next != NULL )
tempnode = tempnode->next;

tempnode1 = createnode();
tempnode1->prev = tempnode;
tempnode1->next = NULL;
tempnode1->data = data;

tempnode->next = tempnode1;
}
}

void DisplayNodes( struct node *head, int direction )
{
if( direction == 1 )
{
{
}
}
else
{

{
}
}
printf("\n");
}

/* my output
3 2 1
1 2 3
3 2 1
1 2 3
3 2 1
1 2 3
3 2 1
1 2 3
3 2 1
1 2 3
*/```
This code is just a demo of how the struct is defined for doublely LL and how to call them, build then and display then in alternative direction.

ssharish2005

6. thanks guys for that ill build upon that