Posts

Showing posts from March, 2021

#21_Doubly linked list

  #include   <stdio.h> #include   <stdlib.h> //Doubly linked list struct   node {      int  data;      struct   node   * prev;      struct   node   * next; }; void   traverse ( struct   node   * head ) {      struct   node   * ptr  =   head ;      while  (ptr->next  !=   NULL )     {          printf ( " %d  " ,  * ptr);         ptr  =  ptr->next;     }      printf ( " %d  " ,  * ptr);      while  (ptr->prev  !=   NULL )     {          printf ( " %d  " ,  * ptr);      ...

#20_Circular linked list

  #include   <stdio.h> #include   <stdlib.h> //Circular linked list struct   node {      int  data;      struct   node   * next; }; void   traverse ( struct   node   * head ); struct   node   * insertion_1 ( struct   node   * head ,  int   data );             //Insertion at first struct   node   * insertion_2 ( struct   node   * head ,  int   data );             //Insertion at end struct   node   * insertion_3 ( struct   node   * head ,  int   data ,  int   index );  //Insertion in between struct   node   * deletion_1 ( struct   node   * head );          ...

#18_Deletion of a node in a linked list

  #include   <iostream> using   namespace   std ; //Deletion of a node in a linked list struct   node {      int  data;      struct   node   * next; }; void   linked_List_Traverse ( struct   node   * head ) {      while  ( head   !=   NULL )     {          printf ( " %d  " ,  * head );          head   =   head ->next;     }      printf ( " \n " ); } struct   node   * Deletion_1 ( struct   node   * head ) {  //Deletion at the beginning of linked list      head   =   head ->next;      return   head ; } struct   node   * Deletion_2 ( struct ...

#16_Insertion in a linked list

  #include   <stdio.h> #include   <stdlib.h> //Insertion in a linked list struct   node {      int  data;      struct   node   * next; }; void   linked_List_Traverse ( struct   node   * head ) {      while  ( head   !=   NULL )     {          printf ( " %d  " ,  * head );          head   =   head ->next;     }      printf ( " \n " ); } struct   node   * Insertion_1 ( struct   node   * head ,  int   data ) {  //Insertion of a node at the beginning of a linked list      struct   node   * ptr  =  ( struct   node   * ) malloc ( sizeof ( struct ...

#14_Linked list creation and deletion

  #include   <stdio.h> #include   <stdlib.h> //Linked list creation and deletion struct   node {      int  data;      struct   node   * next; }; void   linked_List_Traverse ( struct   node   * head ) {      while  ( head   !=   NULL )     {          printf ( " %d  " ,  * head );          head   =   head ->next;     }      printf ( " \n " ); } int   main () {      struct   node   * head;      struct   node   * first;      struct   node   * second;      struct   node   * third;      struct   node   * fourth;   ...