Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using c++ languages , plase don't use malloc and calloc because i did not study them yet. this is example of how the language should

using c++ languages , plase don't use malloc and calloc because i did not study them yet. this is example of how the language should look like
struct Employee{
string name;
int id;
Employee *prev, *next;
};
Employee *temp=NULL, *head=NULL, *tail=NULL *cur=NULL;
B. Insert at Front
void InsertFront()
{
temp = new Employee;
cout
cin>>temp->name;
cout
cin>>temp->id;
temp->prev=NULL;
temp->next=NULL;
if (head==NULL)
{
head=temp;
tail=temp;
}
else
{
temp->next=head;
head->prev=temp;
head=temp;
}
}
C. Insert at Rear
void InsertRear()
{
temp = new Employee;
cout
cin>>temp->name;
cout
cin>>temp->id;
temp->prev=NULL;
temp->next=NULL;
if (head==NULL)
{
head=temp;
tail=temp;
}
else
{
tail->next=temp;
temp->prev=tail;
tail=temp;
}
}
D. Delete from Front
void DeleteFront()
{
temp = head;
if(head==NULL)
{
cout
}
else
{
if(head->next==NULL)
{
head=NULL;
tail=NULL;
}
else
{
head = head->next;
head->prev = NULL;
}
coutname id
delete temp;
}
cout
}
E. Delete from Rear
void DeleteRear()
{
temp=tail;
if(head==NULL)
{
cout
}
else
{
if(head->next==NULL)
{
head=NULL;
tail=NULL;
}
else
{
tail=tail->prev;
tail->next=NULL;
}
coutname id
delete temp;
}
cout
}
F. Print Forward
void PrintForward()
{
cur=head;
if(head==NULL)
{
cout
}
else
{
cout
while(cur!=NULL)
{
coutname id
cur=cur->next;
}
cout
}
}
G. Print Backward
void PrintBackward()
{
cur=tail;
if(head==NULL)
{
cout
}
else
{
cout
while(cur!=NULL)
{
coutname id
cur=cur->prev;
}
cout
}
}
H. Driver Code
int main(){
int choice;
do{
cout
cout
cout
cout
cout
cout
cout
cout
cin>>choice;
switch (choice){
case 1:
InsertFront();
break;
case 2:
InsertRear();
break;
case 3:
DeleteFront();
break;
case 4:
DeleteRear();
break;
case 5:
PrintForward();
break;
case 6:
PrintBackward();
break;
case 7:
cout
break;
default:
cout
}
}while (choice!=7);
return 0;
}
this is the question:
image text in transcribed
Practice Questions: 1- Add a function in the program above to insert a new node at the middle 2. Add a function in the program above to delete a new node from the middle. Part 2: Lab Tasks (10 points) Note: Copy this section into a new word file then save it. You will only submit this section of the lab manual. - Implement a Circular Singly Linked List. Providing the following operations: a. Insert at front b. Insert at rear. c. Delete from front. d. Delete from rear. e. Print the list in forward direction. Bonus Question - Implement a Circular Doubly Linked List. Providing the following operations: a. Insert at front b. Insert at rear. c. Delete from front d. Delete from rear. e Print the list in forward direction. c. Print the list in backward direction

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

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions