We have a linklist which is made of alphabets. We have to shift the vowels towards the end of the linklist, without changing the order in which they appear. So,A->C->E->F->G->Oshould becomeC->F->G->A->E->OThis is the code I have written#include<iostream>using namespace std;struct node{    char ch;    node *next;};void enqueue (node **head, node **tail, char val){    node *newn = (node *)malloc(sizeof(node));    newn->ch = val;    newn->next = NULL;    if (*head == NULL)    {        *head = newn;        *tail = newn;    }    (*tail)->next = newn;    (*tail) = newn;}void print (node *head){    while (head!=NULL)    {        cout<<head->ch<< ;        head = head->next;    }    cout<<endl;}bool isVowel (char ch){    ch = ch | 32;    if (ch == 'a' || ch =='e' || ch=='i' || ch=='o' || ch=='u')        return true;    return false;}node* segregateVowels (node *head, node *tail){    if (head == NULL || head->next == NULL)        return head;    node *temp = head;    node *fin = tail;    while (temp->next!=fin)    {        cout<<temp->ch<< <<fin->ch<<endl;        if (isVowel(temp->next->ch))        {            node *shift = temp->next;            temp->next = temp->next->next;            tail->next = shift;            shift->next = NULL;            tail = shift;        }        else            temp = temp->next;    }    if (temp->next!=NULL && isVowel(temp->next->ch))   /* Handling the case where the last element is a vowel   */    {        node *toMove = temp->next;        temp->next = temp->next->next;        tail->next = toMove;        toMove->next = NULL;    }    else        temp = temp->next;    if (isVowel(head->ch))                  /*  Handling the case where the first element is a vowel    */    {        node *toMove = head;        head = head->next;        toMove->next = temp->next;        temp->next = toMove;    }    return head;}int main(){    srand(time(NULL));    node  *head = NULL, *tail = NULL;    int i = 20;    while (i>=0)    {        enqueue (&head, &tail, rand()%26+65);        i--;    }    print(head);    head = segregateVowels (head, tail);    print(head);}Although this does seem to give me correct results, but I have to explicitly check for two edge cases. Also I feel there is a better solution for this problem or a better approach which I seem to be missing. The problem can be handled by creating two separate Link Lists too, and then joining them together. But what modifications do you suggest in the above program?
Shift vowels towards the end of a Single Linked List
c++;linked list