Write a segment of code to perform each of the following ope
Solution
struct node                                             // Strucutre of Queue
 {
         int d;
         struct node *next;
       
 }
 splitQueue(struct node *front, struct node *rear)               // front is pointing the first node of queue and rear is pointing to last.
 {
         struct node *last, *secondElement, *copy1, *copy2;      // Copy1 for first half part and copy2 for second half part.
         last=rear;                                      // A. set last equal to rear element.
         secondElement = front->next;                    // B. set secondElement to second element of Queue.
         copy1 = front;                                  // C. Making copy of Queue by assigning the front
         copy2 = front;                                  // C. Making copy of Queue by assigning the front
         while(copy2->next!=NULL || copy2 != NULL)       // Finding middle element of Queue.
         {
                 copy1 = copy1->next;                    // Moving copy1 queue to one next
                 copy2 = copy2->next->next;              // Moving copy2 queue to two next
         }                                               // if copy2 at last position then copy1 should be in middle position of queue.
         copy2 = copy1->next;                            // So copy2 will start from copy1->next
         copy1->next= NULL;                              // copy1 will end with this middle position.
         copy1 = front;                                  // copy1 will start from front.
 }
So copy1 is first half part and copy2 is second half part of Queue.

