LinkedList
Linked list is a data structure, contains the reference(link) of next record in a sequence
- LinkedList is a Dynamic Datastructre, It grows and shrinks during runtime
- Insertion and deletion operations are easier and faster
- Efficent, Memory Utilization, i,e No need to preallocate Memory
- Linear Data Structure such as Stack, Queue can be implemented using LinkedList
C Program to Reverse Single Linked List
reverse(struct node **x)
{
Struct node *q, *r, *s;
*q=*x;
r=NULL;
while(q!=NULL)
{
s=r;
r=q;
q=q->link;
r->link=s;
}
*x=r;
}
C Program to Reverse Double LinkedList
void reverse(struct node **head_ref)
{
struct node *temp = NULL;
struct node *current = *head_ref;
while (current != NULL) {
temp = current->prev;
current->prev = current->next;
current->next = temp;
current = current->prev;
}
if(temp != NULL )
*head_ref = temp->prev;
}
