Linked Lists implementation on Lists Executive Summary: Linked list implementati
ID: 3913740 • Letter: L
Question
Linked Lists implementation on Lists Executive Summary: Linked list implementation on lists includes two parts: Data part - stores an element of the list Next part- stores link/pointer to next element You are asked to implement Lists through Linked Lists to perform basic ADT functions. Project Objective: in completing this project, you will Enhance your ability to understand Lists Familiar with the idea of linked list Enable yourself to perform Linked Lists programming skills Due Dates and Honor: This project will be due by the beginning of the class on 7/16/2018. This is an independent programming project, and it is very important that you understand and abide by the policy concerning programming projects. Remember, your personal honor and integrity is far more important than your grade on the project. Detailed Specification: Understand and run the following code. Take a snapshot of the program output. 1. tincludeciostream> using namespace std: class node public: int data; node 'next: class PointerListExplanation / Answer
///modifying insert method
void insert(int preptr_value, int element)
{ //declaraing
//new node to insert
node *newptr = newnode;
newptr->data =element;
//finding position of preptr_value
if(top==NULL)//means preptr_value not in the list
{
cout<<"Error: "<<preptr_value<<" Not in the list ";
}
else
{
//finding preptr_value position in list..
node *temp = top;
while(temp->next!=top)
{
if(temp->data==preptr_value)
{
break;//if position is found
}
}
if(temp==top)
{
if(top->data!=preptr_value)
cout<<"Error: "<<preptr_value<<" Not in the list ";
else
{
newptr->next =top;
top = newptr;
}
}
else
{
//linking / inserting into list
newptr->next =temp->next;
temp->next = newptr;
}
}
}
//modifying remove method
void remove(int preptr_value)
{
//finding position of preptr_value
if(top==NULL)//means preptr_value not in the list
{
cout<<"Error: "<<preptr_value<<" Not in the list ";
}
else
{
//finding preptr_value position in list..
node *temp = top;
while(temp->next!=top)
{
if(temp->data==preptr_value)
{
break;//if position is found
}
}
if(temp==top)
{
if(top->data!=preptr_value)
cout<<"Error: "<<preptr_value<<" Not in the list ";
else
cout<<"Contains only one value...Deletion can't be done ";
}
else
{
node *temp1 = temp->next;
temp->next= temp1->next;
delete(temp1);//deleting node..
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.