Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem Design and implement your own linked list template class and methods. Yo

ID: 3764785 • Letter: P

Question

Problem Design and implement your own linked list template class and methods. You will test your new template class using a driver program. The driver program should do the following:

• Create a list of integers,

• Add five integers to the list,

• Display the list,

• Remove a selected integer,

• Display the list,

• Empty the list.

• Create a list of strings,

• Add five strings to the list,

• Display the list,

• Remove a selected string,

• Display the list,

• Empty the list and exit.

The list should keep its elements ordered (ascending).

Your implementation should not use std:list, but rather build one using pointers. Use the example in the textbook and slides. .

Items to submit

• Source codes (commented, with header information) + any necessary additional files so that the code compile and runs properly. Put class and header in separate files

Explanation / Answer

#include<iostream.h>
int main()
int rear=-1;
int front=-1;
#define MAX 5
int queue_cur[MAX];
class queue
{
public:
class FULL{};
class EMPTY{};
void insert();
void del();
void display();
};
void main()
{
queue q;
int choice;
while(1)
{
cout<<" *** QUEUE USING EXCEPTION HANDLING*** ";
cout<<" 1.insert 2.delete 3.display 4.exit ";
cout<>choice;
switch(choice)
{
case 1:
try
{
q.insert();
}
catch(queue::FULL)
{
cout<<" ***QUEUE OVERFLOW***";
}
break;
case 2:
try
{
q.del();
}
catch(queue::EMPTY)
{
cout<<" ***QUEUE EMPTY***";
}
break;
case 3:
try
{
q.display();
}
catch(queue::EMPTY)
{
cout<<" ***QUEUE EMPTY***";
}
break;
case 4:
exit(1);
default:
cout<<"wrong choice";
}
}
}
void queue::insert()
{
int added_item;
if(rear==MAX-1)
throw FULL();
else
{
if(front==-1)
front=0;
cout<>added_item;
rear=rear+1;
queue_cur[rear]=added_item;
}
}
void queue::del()
{
if(front==-1||front>rear)
{
throw EMPTY();
return;
}
else
{
cout<<" Element deleted from queue is : "<<queue_cur[front];
front=front+1;
}
}
void queue::display()
{
int i;
if(front==-1)
throw EMPTY();
else
{
cout<<"Queue is: ";
for(i=front;i<=rear;i++)
cout<<queue_cur[i];
cout<<" ";
}
}

OUTPUT:-
*** QUEUE USING EXCEPTION HANDLING***
1.insert
2.delete
3.display
4.exit
Enter ur choice3
***QUEUE EMPTY***
*** QUEUE USING EXCEPTION HANDLING***
1.insert
2.delete
3.display
4.exit
Enter ur choice 1
Input the element for adding in queue10
*** QUEUE USING EXCEPTION HANDLING***
1.insert
2.delete
3.display
4.exit
Enter ur choice3
Queue is:   10
*** QUEUE USING EXCEPTION HANDLING***
1.insert
2.delete
3.display
4.exit
Enter ur choice 1
Input the element for adding in queue20
*** QUEUE USING EXCEPTION HANDLING***
1.insert
2.delete
3.display
4.exit
Enter ur choice1
Input the element for adding in queue30
*** QUEUE USING EXCEPTION HANDLING***
1.insert
2.delete
3.display
4.exit
Enter ur choice1
Input the element for adding in queue40
*** QUEUE USING EXCEPTION HANDLING***
1.insert
2.delete
3.display
4.exit
Enter ur choice1
Input the element for adding in queue50
*** QUEUE USING EXCEPTION HANDLING***
1.insert
2.delete
3.display
4.exit
Enter ur choice1
***QUEUE OVERFLOW***
*** QUEUE USING EXCEPTION HANDLING***
1.insert
2.delete
3.display
4.exit
Enter ur choice
Queue is:   1020304050
*** QUEUE USING EXCEPTION HANDLING***
1.insert
2.delete
3.display
4.exit
Enter ur choice2
Element deleted from queue is :   10
*** QUEUE USING EXCEPTION HANDLING***
1.insert
2.delete
3.display
4.exit
Enter ur choice2
Element deleted from queue is :   20
*** QUEUE USING EXCEPTION HANDLING***
1.insert
2.delete
3.display
4.exit
Enter ur choice2
Element deleted from queue is :   30
*** QUEUE USING EXCEPTION HANDLING***
1.insert
2.delete
3.display
4.exit
Enter ur choice2
Element deleted from queue is :   40
*** QUEUE USING EXCEPTION HANDLING***
1.insert
2.delete
3.display
4.exit
Enter ur choice2
Element deleted from queue is :   50
*** QUEUE USING EXCEPTION HANDLING***
1.insert
2.delete
3.display
4.exit
Enter ur choice2
***QUEUE EMPTY***
*** QUEUE USING EXCEPTION HANDLING***
1.insert
2.delete
3.display
4.exit
Enter ur choice 4

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote