Page 136 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 136

Unit 8: Operations on Linked List




               Create a temporary which will point to head. Also, update the tail nodes next pointer to  Notes
               point to next node of head (as shown below).

                            Figure 8.38: Creating a Temporary Pointing to Head














          Source: http://www.csie.ntu.edu.tw/~hsinmu/courses/lib/exe/fetch.php?media=dsa_12spring:
          dsame_chap3.pdf

               Now, move the head pointer to next node. Create a temporary which will point to head.
               Also, update the tail nodes next pointer to point to next node of head (as shown below).

                             Figure 8.39: Move the Head Pointer to Next Node













          Source: http://www.csie.ntu.edu.tw/~hsinmu/courses/lib/exe/fetch.php?media=dsa_12spring:
          dsame_chap3.pdf
          The code is given below.
          void DeleteFrontNodeFromCLL (struct CLLNode **head) {
          struct CLLNode *temp = *head;
          struct CLLNode *current = *head;
          if(*head == NULL) {
          printf(“List Empty”);
          return;
          }
          while (current—>next != *head)
          current = current—>next;
          current—> next = *head—>next;
          *head = *head—>)next;
          free(temp);
          return;
          }








                                           LOVELY PROFESSIONAL UNIVERSITY                                   129
   131   132   133   134   135   136   137   138   139   140   141