Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 2 : In class, you were given the source code for building a queue data structure based on a linked list. You are given

Part 2:
In class, you were given the source code for building a queue data structure based on a linked list. You are given this source code (assign4_part2.cpp) but it misses the implementation of the "vowelCheck" fuction. You are asked to provide the implementation of this function as described below.
The vowelCheck fucntion receives two queues and copies the elements from the first queue into the second queue when the element value is not vowel.
Hint: Vowel Letters are {A,O,I,E,U,a,o,i,e,u}.
\table[[\table[[Example of Input Queues to the function],
Import Notes:
You are NOT allowed to change the parameters given for the "oddCheck" and "vowelCheck" functions. #include
using namespace std;
struct Node {
char data;
struct Node *next;
};
char peek(Node *front, Node *rear){ return front->data; }
void enqueue(Node **front, Node **rear, int data){
Node *newNode = new Node;
newNode->data = data;
newNode->next = NULL;
if (*front == NULL){
*front = newNode;
*rear = newNode;
} else {
(*rear)->next = newNode;
*rear = newNode;
}
}
char dequeue(Node **front, Node **rear){
Node *temp =*front;
char x =(*front)->data; // or int x = temp -> data;
*front =(*front)->next;
if (*front == NULL)
*rear = NULL;
delete temp;
return x;
}
void printQueue(Node *front, Node *rear){
if(front != NULL){
Node *curr = front;
while (curr->next != NULL){
cout curr->data "";
curr = curr->next;
}
cout curr->data "";
cout endl;
}
}
void VowelCheck(Node *front1, Node *rear1, Node **front2, Node **rear2){
}
int main(){
Node *front1= NULL;
Node *rear1= NULL;
Node *front2= NULL;
Node *rear2= NULL;
enqueue(&front1, &rear1,'M');
enqueue(&front1, &rear1,'o');
enqueue(&front1, &rear1,'h');
enqueue(&front1, &rear1,'a');
enqueue(&front1, &rear1,'m');
enqueue(&front1, &rear1,'m');
enqueue(&front1, &rear1,'a');
enqueue(&front1, &rear1,'d');
printQueue(front1, rear1);
VowelCheck(front1, rear1, &front2, &rear2);
printQueue(front2, rear2);
return 0;
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions