SlideShare a Scribd company logo
1 of 15
Download to read offline
implement the ListLinked ADT (the declaration is given in ListLinked.h)(60 points)
- implement the following operations:
- constructor, assignment operator, destructor
- insert, remove, replace, clear
- isFull, isEmpty
- gotoBeginning, gotoEnd, gotoNext, gotoPrior, getCursor
implement the function moveToBeginning() that removes the data item marked by the cursor and
reinserts it at the beginning of the list
- implement the function insertBefore(..) that will insert the new data item before the cursor or if
the list is empty as the first element of the list
#include "ListLinked.h"
// ListNode member functions
template
List::ListNode::ListNode(const DataType& nodeData, ListNode* nextPtr)
{
this->dataItem = nodeData;
this->next = nextPtr;
}
// List member functions
template
List::List(int ignored = 0)
{
}
template
List::List(const List& other)
{
}
template
List& List::operator=(const List& other)
{
}
template
List::~List()
{
}
template
void List::insert(const DataType& newDataItem) throw (logic_error)
{
}
template
void List::remove() throw (logic_error)
{
}
template
void List::replace(const DataType& newDataItem) throw (logic_error)
{
}
template
void List::clear()
{
}
template
bool List::isEmpty() const
{
return false;
}
template
bool List::isFull() const
{
return false;
}
template
void List::gotoBeginning() throw (logic_error)
{
}
template
void List::gotoEnd() throw (logic_error)
{
}
template
bool List::gotoNext() throw (logic_error)
{
return false;
}
template
bool List::gotoPrior() throw (logic_error)
{
return false;
}
template
DataType List::getCursor() const throw (logic_error)
{
DataType t;
return t;
}
template
void List::moveToBeginning () throw (logic_error)
{
}
template
void List::insertBefore(const DataType& newDataItem) throw (logic_error)
{
}
#include "show5.cpp"
Solution
#include
#include
#include
using namespace std;
struct Node
{
int data;
Node *next;
};
Node *tail=NULL;
Node* Insert_atHead(Node *head, int data)
{
Node *temp=new Node;
temp->data=data;
temp->next=head;
head=temp;
return head;
}
Node* Insert_atTail(Node *head, int data)
{
Node *tail=head;
if(tail==NULL)
{
Node *temp = new Node;
temp->data=data;
temp->next=NULL;
head=temp;
return head;
}
while(tail!= NULL)
{
if(tail->next==NULL)
{
Node *temp=new Node;
temp->data=data;
temp->next=NULL;
tail->next=temp;
return tail;
}
else
{
tail=tail->next;
}
}
}
Node *Insert_atPosition(Node *head, int data, int position)
{
int i=0;
int j=position-1;
if(position==0)
{
Node *temp = new Node;
temp->data=data;
temp->next=head;
head=temp;
return head;
}
else
{
Node *temp=head;
while(inext;
i++;
}
Node *temp1 = new Node;
temp1->data=data;
temp1->next=temp->next;
temp->next=temp1;
return head;
}
return head;
}
Node* Delete(Node *head, int position)
{
Node *temp=head;
int i=1;
int j=position;
if(j==0)
{
head=head->next;
return head;
}
Node *temp1 = new Node;
while(j>0)
{
temp1=temp;
temp=temp->next;
j--;
}
temp1->next=temp->next;
delete temp;
return head;
}
int GetNode(Node *head,int positionFromTail)
{
Node *tail=head;
int l=0;
while(tail->next!=NULL)
{
tail=tail->next;
l++;
}
int i=(l-positionFromTail);
Node *temp=head;
while(i>0)
{
temp=temp->next;
i--;
}
return temp->data;
}
int Size_ofLinkedList(Node *head)
{
int S=0;
Node *temp = head;
while(temp!= NULL)
{
S++;
temp=temp->next;
}
return S;
}
Node *Reverse_LinkedList(Node *head)
{
Node *temp1 = head;
Node *tail = NULL;
Node *head1= new Node;
while(head!=NULL)
{
head1=head;
temp1=temp1->next;
head->next=tail;
tail=head;
head=temp1;
}
head=head1;
}
int CompareLists(Node *headA, Node* headB)
{
Node *tempA=headA;
Node *tempB=headB;
while(tempA!=NULL && tempB!=NULL)
{
if(tempA->data==tempB->data)
{
tempA=tempA->next;
tempB=tempB->next;
}
else
{
return 0;
}
}
if(tempA==NULL && tempB==NULL)
{
return 1;
}
else
{
return 0;
}
}
int FindMergeNode(Node *headA, Node *headB)
{
Node *tempA=headA;
Node *tempB=headB;
int m=0;
int n=0;;
while(tempA!=NULL)
{
tempA=tempA->next;
m++;
}
while(tempB!=NULL)
{
tempB=tempB->next;
n++;
}
tempA=headA;
tempB=headB;
int Data;
if(m>n)
{
int p=m-n;
while(p>0)
{
tempA=tempA->next;
p--;
}
while(tempA!=tempB)
{
tempA=tempA->next;
tempB=tempB->next;
}
Data=tempA->data;
}
else
{
int p = n-m;
while(p>0)
{
tempB=tempB->next;
p--;
}
while(tempA!=tempB)
{
tempA=tempA->next;
tempB=tempB->next;
}
Data=tempA->data;
}
return Data;
}
Node* RemoveDuplicates(Node *head)
{
Node *temp=head;
Node *temp1 = new Node;
while(temp->next!=NULL)
{
if(temp->data!=(temp->next)->data)
{
temp=temp->next;
}
else
{
temp1=temp->next;
temp->next=temp1->next;
delete temp1;
}
}
return head;
}
Node* MergeLists(Node *headA, Node* headB)
{
Node *temp = new Node;
Node *head = new Node;
if(headA==NULL || headB==NULL)
{
if(headA==NULL)
{
head=headB;
}
else
{
head=headA;
}
return head;
}
if(headA->data<=headB->data)
{
temp=headA;
headA=headA->next;
}
else
{
temp=headB;
headB=headB->next;
}
head=temp;
while(headA!=NULL && headB!=NULL)
{
if(headA->data<=headB->data)
{
temp->next=headA;
temp=temp->next;
headA=headA->next;
}
else
{
temp->next=headB;
temp=temp->next;
headB=headB->next;
}
}
if(headA==NULL && headB!=NULL)
{
temp->next=headB;
}
if(headA!=NULL && headB==NULL)
{
temp->next=headA;
}
return head;
}
int HasCycle(Node* head)
{
Node *temp1=head;
Node *temp2=head;
int X=0;
if(head==NULL || head->next==NULL)
{
X=0;
}
else
{
temp1=temp1->next;
temp2=(temp2->next)->next;
while(temp1!=temp2)
{
if(temp2->next==NULL || (temp2->next)->next==NULL)
{
X=0;
break;
}
temp1=temp1->next;
temp2=(temp2->next)->next;
X=1;
}
}
if(X==0)
{
return 0;
}
else
{
return 1;
}
}
void Print(Node *head)
{
Node *temp = head;
while(temp!= NULL)
{
cout<data<< " --> ";
temp=temp->next;
}
cout<< "NULL";
}
void ReversePrint(Node *head)
{
Node *temp1 = head;
Node *tail = NULL;
Node *head1= new Node;
if(head!=NULL)
{
while(head!=NULL)
{
head1=head;
temp1=temp1->next;
head->next=tail;
tail=head;
head=temp1;
}
Node *temp=head1;
while(temp!= NULL)
{
cout<data<< " ";
temp=temp->next;
}
}
}
int main() {
int data;
Node *head=NULL;
int H;
cout<< "No. of Node Insertion at Head: ";
cin>>H;
while(H>0)
{
cin>>data;
head=Insert_atHead(head, data);
H--;
}
int T;
cout<< "No. of Node Insertion at Tail: ";
cin>>T;
while(T>0)
{
cin>>data;
Insert_atTail(head,data);
T--;
}
int P;
cout<< " ";
cout<< "Add Node at Position: ";
cin>>P;
cout<< " ";
cout<< "data: ";
cin>>data;
Insert_atPosition(head,data,P);
cout<< " ";
cout<< "Delete Node at Position: ";
cin>>P;
Delete(head,P);
cout<< " ";
Print(head);
Reverse_LinkedList(head);
head=tail;
cout<< " ";
Print(head);
cout<< " ";
cout<< "Size of LinkedList: "<

More Related Content

Similar to implement the ListLinked ADT (the declaration is given in ListLinked.pdf

Please need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdfPlease need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdfnitinarora01
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxteyaj1
 
Write a program to find the number of comparisons using the binary se.docx
 Write a program to find the number of comparisons using the binary se.docx Write a program to find the number of comparisons using the binary se.docx
Write a program to find the number of comparisons using the binary se.docxajoy21
 
To complete the task, you need to fill in the missing code. I’ve inc.pdf
To complete the task, you need to fill in the missing code. I’ve inc.pdfTo complete the task, you need to fill in the missing code. I’ve inc.pdf
To complete the task, you need to fill in the missing code. I’ve inc.pdfezycolours78
 
Implement the ListArray ADT-Implement the following operations.pdf
Implement the ListArray ADT-Implement the following operations.pdfImplement the ListArray ADT-Implement the following operations.pdf
Implement the ListArray ADT-Implement the following operations.pdfpetercoiffeur18
 
Linked list imp of list
Linked list imp of listLinked list imp of list
Linked list imp of listElavarasi K
 
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdfpasqualealvarez467
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfJUSTSTYLISH3B2MOHALI
 
double linked list header file code#include iostream#include.pdf
double linked list header file code#include iostream#include.pdfdouble linked list header file code#include iostream#include.pdf
double linked list header file code#include iostream#include.pdffacevenky
 
#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdf#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdfankitmobileshop235
 
Revisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queueRevisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queuessuser7319f8
 
take the following code and give details of what each line of code i.pdf
take the following code and give details of what each line of code i.pdftake the following code and give details of what each line of code i.pdf
take the following code and give details of what each line of code i.pdffastechsrv
 
ItemNodeh include ltiostreamgt include ltstring.pdf
ItemNodeh    include ltiostreamgt include ltstring.pdfItemNodeh    include ltiostreamgt include ltstring.pdf
ItemNodeh include ltiostreamgt include ltstring.pdfacmefit
 

Similar to implement the ListLinked ADT (the declaration is given in ListLinked.pdf (20)

137 Lab-2.2.pdf
137 Lab-2.2.pdf137 Lab-2.2.pdf
137 Lab-2.2.pdf
 
dynamicList.ppt
dynamicList.pptdynamicList.ppt
dynamicList.ppt
 
Lab-2.2 717822E504.pdf
Lab-2.2 717822E504.pdfLab-2.2 717822E504.pdf
Lab-2.2 717822E504.pdf
 
Please need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdfPlease need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdf
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docx
 
Write a program to find the number of comparisons using the binary se.docx
 Write a program to find the number of comparisons using the binary se.docx Write a program to find the number of comparisons using the binary se.docx
Write a program to find the number of comparisons using the binary se.docx
 
To complete the task, you need to fill in the missing code. I’ve inc.pdf
To complete the task, you need to fill in the missing code. I’ve inc.pdfTo complete the task, you need to fill in the missing code. I’ve inc.pdf
To complete the task, you need to fill in the missing code. I’ve inc.pdf
 
Unit - 2.pdf
Unit - 2.pdfUnit - 2.pdf
Unit - 2.pdf
 
Implement the ListArray ADT-Implement the following operations.pdf
Implement the ListArray ADT-Implement the following operations.pdfImplement the ListArray ADT-Implement the following operations.pdf
Implement the ListArray ADT-Implement the following operations.pdf
 
Linked list imp of list
Linked list imp of listLinked list imp of list
Linked list imp of list
 
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
 
double linked list header file code#include iostream#include.pdf
double linked list header file code#include iostream#include.pdfdouble linked list header file code#include iostream#include.pdf
double linked list header file code#include iostream#include.pdf
 
Linked lists
Linked listsLinked lists
Linked lists
 
#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdf#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdf
 
Revisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queueRevisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queue
 
take the following code and give details of what each line of code i.pdf
take the following code and give details of what each line of code i.pdftake the following code and give details of what each line of code i.pdf
take the following code and give details of what each line of code i.pdf
 
17 linkedlist (1)
17 linkedlist (1)17 linkedlist (1)
17 linkedlist (1)
 
ItemNodeh include ltiostreamgt include ltstring.pdf
ItemNodeh    include ltiostreamgt include ltstring.pdfItemNodeh    include ltiostreamgt include ltstring.pdf
ItemNodeh include ltiostreamgt include ltstring.pdf
 
Lab-2.4 101.pdf
Lab-2.4 101.pdfLab-2.4 101.pdf
Lab-2.4 101.pdf
 

More from FOREVERPRODUCTCHD

You are asked with writing a program in C that manages contact infor.pdf
You are asked with writing a program in C that manages contact infor.pdfYou are asked with writing a program in C that manages contact infor.pdf
You are asked with writing a program in C that manages contact infor.pdfFOREVERPRODUCTCHD
 
Write a short paragraph explaining what the exploit does in Assembly.pdf
Write a short paragraph explaining what the exploit does in Assembly.pdfWrite a short paragraph explaining what the exploit does in Assembly.pdf
Write a short paragraph explaining what the exploit does in Assembly.pdfFOREVERPRODUCTCHD
 
Write a program to convert a given INFIX into POSTFIX. Make sure .pdf
Write a program to convert a given INFIX into POSTFIX. Make sure .pdfWrite a program to convert a given INFIX into POSTFIX. Make sure .pdf
Write a program to convert a given INFIX into POSTFIX. Make sure .pdfFOREVERPRODUCTCHD
 
What quality control mechanisms should major accounting firms have i.pdf
What quality control mechanisms should major accounting firms have i.pdfWhat quality control mechanisms should major accounting firms have i.pdf
What quality control mechanisms should major accounting firms have i.pdfFOREVERPRODUCTCHD
 
What are three basic ethical principles for journalism Why are ethi.pdf
What are three basic ethical principles for journalism Why are ethi.pdfWhat are three basic ethical principles for journalism Why are ethi.pdf
What are three basic ethical principles for journalism Why are ethi.pdfFOREVERPRODUCTCHD
 
What are some of the different versions of UNIX® Why is it importan.pdf
What are some of the different versions of UNIX® Why is it importan.pdfWhat are some of the different versions of UNIX® Why is it importan.pdf
What are some of the different versions of UNIX® Why is it importan.pdfFOREVERPRODUCTCHD
 
Type in your own words In details, discuss the following questions.pdf
Type in your own words In details, discuss the following questions.pdfType in your own words In details, discuss the following questions.pdf
Type in your own words In details, discuss the following questions.pdfFOREVERPRODUCTCHD
 
Twice a first number decreased by a second number is 11. The first nu.pdf
Twice a first number decreased by a second number is 11. The first nu.pdfTwice a first number decreased by a second number is 11. The first nu.pdf
Twice a first number decreased by a second number is 11. The first nu.pdfFOREVERPRODUCTCHD
 
the largest drum ever constructed was played at the Rotal festival H.pdf
the largest drum ever constructed was played at the Rotal festival H.pdfthe largest drum ever constructed was played at the Rotal festival H.pdf
the largest drum ever constructed was played at the Rotal festival H.pdfFOREVERPRODUCTCHD
 
Suppose that the material that you are recrystallizing fails to perc.pdf
Suppose that the material that you are recrystallizing fails to perc.pdfSuppose that the material that you are recrystallizing fails to perc.pdf
Suppose that the material that you are recrystallizing fails to perc.pdfFOREVERPRODUCTCHD
 
Summarize the purpose of a WAN and define what makes up a WAN connec.pdf
Summarize the purpose of a WAN and define what makes up a WAN connec.pdfSummarize the purpose of a WAN and define what makes up a WAN connec.pdf
Summarize the purpose of a WAN and define what makes up a WAN connec.pdfFOREVERPRODUCTCHD
 
SOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdf
SOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdfSOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdf
SOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdfFOREVERPRODUCTCHD
 
Step 12 The task is complete when the quota can be verified. Take a.pdf
Step 12  The task is complete when the quota can be verified.  Take a.pdfStep 12  The task is complete when the quota can be verified.  Take a.pdf
Step 12 The task is complete when the quota can be verified. Take a.pdfFOREVERPRODUCTCHD
 
QUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdf
QUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdfQUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdf
QUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdfFOREVERPRODUCTCHD
 
Python program with functions that extracts specific characters from.pdf
Python program with functions that extracts specific characters from.pdfPython program with functions that extracts specific characters from.pdf
Python program with functions that extracts specific characters from.pdfFOREVERPRODUCTCHD
 
Please answer the following question and all its parts. Please exp.pdf
Please answer the following question and all its parts. Please exp.pdfPlease answer the following question and all its parts. Please exp.pdf
Please answer the following question and all its parts. Please exp.pdfFOREVERPRODUCTCHD
 
Please help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdf
Please help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdfPlease help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdf
Please help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdfFOREVERPRODUCTCHD
 
Know the different types of viruses which have a dsRNA genome A type.pdf
Know the different types of viruses which have a dsRNA genome  A type.pdfKnow the different types of viruses which have a dsRNA genome  A type.pdf
Know the different types of viruses which have a dsRNA genome A type.pdfFOREVERPRODUCTCHD
 
In what ways do the experts foresee the use of both virtualization a.pdf
In what ways do the experts foresee the use of both virtualization a.pdfIn what ways do the experts foresee the use of both virtualization a.pdf
In what ways do the experts foresee the use of both virtualization a.pdfFOREVERPRODUCTCHD
 
In the Meselson Stahl experiment, E. coli was grown for many generati.pdf
In the Meselson Stahl experiment, E. coli was grown for many generati.pdfIn the Meselson Stahl experiment, E. coli was grown for many generati.pdf
In the Meselson Stahl experiment, E. coli was grown for many generati.pdfFOREVERPRODUCTCHD
 

More from FOREVERPRODUCTCHD (20)

You are asked with writing a program in C that manages contact infor.pdf
You are asked with writing a program in C that manages contact infor.pdfYou are asked with writing a program in C that manages contact infor.pdf
You are asked with writing a program in C that manages contact infor.pdf
 
Write a short paragraph explaining what the exploit does in Assembly.pdf
Write a short paragraph explaining what the exploit does in Assembly.pdfWrite a short paragraph explaining what the exploit does in Assembly.pdf
Write a short paragraph explaining what the exploit does in Assembly.pdf
 
Write a program to convert a given INFIX into POSTFIX. Make sure .pdf
Write a program to convert a given INFIX into POSTFIX. Make sure .pdfWrite a program to convert a given INFIX into POSTFIX. Make sure .pdf
Write a program to convert a given INFIX into POSTFIX. Make sure .pdf
 
What quality control mechanisms should major accounting firms have i.pdf
What quality control mechanisms should major accounting firms have i.pdfWhat quality control mechanisms should major accounting firms have i.pdf
What quality control mechanisms should major accounting firms have i.pdf
 
What are three basic ethical principles for journalism Why are ethi.pdf
What are three basic ethical principles for journalism Why are ethi.pdfWhat are three basic ethical principles for journalism Why are ethi.pdf
What are three basic ethical principles for journalism Why are ethi.pdf
 
What are some of the different versions of UNIX® Why is it importan.pdf
What are some of the different versions of UNIX® Why is it importan.pdfWhat are some of the different versions of UNIX® Why is it importan.pdf
What are some of the different versions of UNIX® Why is it importan.pdf
 
Type in your own words In details, discuss the following questions.pdf
Type in your own words In details, discuss the following questions.pdfType in your own words In details, discuss the following questions.pdf
Type in your own words In details, discuss the following questions.pdf
 
Twice a first number decreased by a second number is 11. The first nu.pdf
Twice a first number decreased by a second number is 11. The first nu.pdfTwice a first number decreased by a second number is 11. The first nu.pdf
Twice a first number decreased by a second number is 11. The first nu.pdf
 
the largest drum ever constructed was played at the Rotal festival H.pdf
the largest drum ever constructed was played at the Rotal festival H.pdfthe largest drum ever constructed was played at the Rotal festival H.pdf
the largest drum ever constructed was played at the Rotal festival H.pdf
 
Suppose that the material that you are recrystallizing fails to perc.pdf
Suppose that the material that you are recrystallizing fails to perc.pdfSuppose that the material that you are recrystallizing fails to perc.pdf
Suppose that the material that you are recrystallizing fails to perc.pdf
 
Summarize the purpose of a WAN and define what makes up a WAN connec.pdf
Summarize the purpose of a WAN and define what makes up a WAN connec.pdfSummarize the purpose of a WAN and define what makes up a WAN connec.pdf
Summarize the purpose of a WAN and define what makes up a WAN connec.pdf
 
SOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdf
SOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdfSOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdf
SOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdf
 
Step 12 The task is complete when the quota can be verified. Take a.pdf
Step 12  The task is complete when the quota can be verified.  Take a.pdfStep 12  The task is complete when the quota can be verified.  Take a.pdf
Step 12 The task is complete when the quota can be verified. Take a.pdf
 
QUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdf
QUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdfQUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdf
QUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdf
 
Python program with functions that extracts specific characters from.pdf
Python program with functions that extracts specific characters from.pdfPython program with functions that extracts specific characters from.pdf
Python program with functions that extracts specific characters from.pdf
 
Please answer the following question and all its parts. Please exp.pdf
Please answer the following question and all its parts. Please exp.pdfPlease answer the following question and all its parts. Please exp.pdf
Please answer the following question and all its parts. Please exp.pdf
 
Please help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdf
Please help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdfPlease help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdf
Please help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdf
 
Know the different types of viruses which have a dsRNA genome A type.pdf
Know the different types of viruses which have a dsRNA genome  A type.pdfKnow the different types of viruses which have a dsRNA genome  A type.pdf
Know the different types of viruses which have a dsRNA genome A type.pdf
 
In what ways do the experts foresee the use of both virtualization a.pdf
In what ways do the experts foresee the use of both virtualization a.pdfIn what ways do the experts foresee the use of both virtualization a.pdf
In what ways do the experts foresee the use of both virtualization a.pdf
 
In the Meselson Stahl experiment, E. coli was grown for many generati.pdf
In the Meselson Stahl experiment, E. coli was grown for many generati.pdfIn the Meselson Stahl experiment, E. coli was grown for many generati.pdf
In the Meselson Stahl experiment, E. coli was grown for many generati.pdf
 

Recently uploaded

Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 

Recently uploaded (20)

Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 

implement the ListLinked ADT (the declaration is given in ListLinked.pdf

  • 1. implement the ListLinked ADT (the declaration is given in ListLinked.h)(60 points) - implement the following operations: - constructor, assignment operator, destructor - insert, remove, replace, clear - isFull, isEmpty - gotoBeginning, gotoEnd, gotoNext, gotoPrior, getCursor implement the function moveToBeginning() that removes the data item marked by the cursor and reinserts it at the beginning of the list - implement the function insertBefore(..) that will insert the new data item before the cursor or if the list is empty as the first element of the list #include "ListLinked.h" // ListNode member functions template List::ListNode::ListNode(const DataType& nodeData, ListNode* nextPtr) { this->dataItem = nodeData; this->next = nextPtr; } // List member functions template List::List(int ignored = 0) { } template List::List(const List& other) { } template List& List::operator=(const List& other) { } template List::~List() { }
  • 2. template void List::insert(const DataType& newDataItem) throw (logic_error) { } template void List::remove() throw (logic_error) { } template void List::replace(const DataType& newDataItem) throw (logic_error) { } template void List::clear() { } template bool List::isEmpty() const { return false; } template bool List::isFull() const { return false; } template void List::gotoBeginning() throw (logic_error) { } template void List::gotoEnd() throw (logic_error) { } template bool List::gotoNext() throw (logic_error)
  • 3. { return false; } template bool List::gotoPrior() throw (logic_error) { return false; } template DataType List::getCursor() const throw (logic_error) { DataType t; return t; } template void List::moveToBeginning () throw (logic_error) { } template void List::insertBefore(const DataType& newDataItem) throw (logic_error) { } #include "show5.cpp" Solution #include #include #include using namespace std; struct Node { int data; Node *next; }; Node *tail=NULL;
  • 4. Node* Insert_atHead(Node *head, int data) { Node *temp=new Node; temp->data=data; temp->next=head; head=temp; return head; } Node* Insert_atTail(Node *head, int data) { Node *tail=head; if(tail==NULL) { Node *temp = new Node; temp->data=data; temp->next=NULL; head=temp; return head; } while(tail!= NULL) { if(tail->next==NULL) { Node *temp=new Node; temp->data=data; temp->next=NULL; tail->next=temp; return tail; } else { tail=tail->next; } } } Node *Insert_atPosition(Node *head, int data, int position)
  • 5. { int i=0; int j=position-1; if(position==0) { Node *temp = new Node; temp->data=data; temp->next=head; head=temp; return head; } else { Node *temp=head; while(inext; i++; } Node *temp1 = new Node; temp1->data=data; temp1->next=temp->next; temp->next=temp1; return head; } return head; } Node* Delete(Node *head, int position) { Node *temp=head; int i=1; int j=position; if(j==0) { head=head->next; return head; } Node *temp1 = new Node;
  • 6. while(j>0) { temp1=temp; temp=temp->next; j--; } temp1->next=temp->next; delete temp; return head; } int GetNode(Node *head,int positionFromTail) { Node *tail=head; int l=0; while(tail->next!=NULL) { tail=tail->next; l++; } int i=(l-positionFromTail); Node *temp=head; while(i>0) { temp=temp->next; i--; } return temp->data; } int Size_ofLinkedList(Node *head) { int S=0; Node *temp = head; while(temp!= NULL) { S++;
  • 7. temp=temp->next; } return S; } Node *Reverse_LinkedList(Node *head) { Node *temp1 = head; Node *tail = NULL; Node *head1= new Node; while(head!=NULL) { head1=head; temp1=temp1->next; head->next=tail; tail=head; head=temp1; } head=head1; } int CompareLists(Node *headA, Node* headB) { Node *tempA=headA; Node *tempB=headB; while(tempA!=NULL && tempB!=NULL) { if(tempA->data==tempB->data) { tempA=tempA->next; tempB=tempB->next; } else { return 0;
  • 8. } } if(tempA==NULL && tempB==NULL) { return 1; } else { return 0; } } int FindMergeNode(Node *headA, Node *headB) { Node *tempA=headA; Node *tempB=headB; int m=0; int n=0;; while(tempA!=NULL) { tempA=tempA->next; m++; } while(tempB!=NULL) { tempB=tempB->next; n++; } tempA=headA; tempB=headB; int Data; if(m>n) { int p=m-n; while(p>0) {
  • 9. tempA=tempA->next; p--; } while(tempA!=tempB) { tempA=tempA->next; tempB=tempB->next; } Data=tempA->data; } else { int p = n-m; while(p>0) { tempB=tempB->next; p--; } while(tempA!=tempB) { tempA=tempA->next; tempB=tempB->next; } Data=tempA->data; } return Data; } Node* RemoveDuplicates(Node *head) { Node *temp=head; Node *temp1 = new Node; while(temp->next!=NULL) { if(temp->data!=(temp->next)->data) {
  • 10. temp=temp->next; } else { temp1=temp->next; temp->next=temp1->next; delete temp1; } } return head; } Node* MergeLists(Node *headA, Node* headB) { Node *temp = new Node; Node *head = new Node; if(headA==NULL || headB==NULL) { if(headA==NULL) { head=headB; } else { head=headA; } return head; } if(headA->data<=headB->data) { temp=headA; headA=headA->next; } else { temp=headB;
  • 11. headB=headB->next; } head=temp; while(headA!=NULL && headB!=NULL) { if(headA->data<=headB->data) { temp->next=headA; temp=temp->next; headA=headA->next; } else { temp->next=headB; temp=temp->next; headB=headB->next; } } if(headA==NULL && headB!=NULL) { temp->next=headB; } if(headA!=NULL && headB==NULL) { temp->next=headA; } return head; } int HasCycle(Node* head) { Node *temp1=head; Node *temp2=head;
  • 12. int X=0; if(head==NULL || head->next==NULL) { X=0; } else { temp1=temp1->next; temp2=(temp2->next)->next; while(temp1!=temp2) { if(temp2->next==NULL || (temp2->next)->next==NULL) { X=0; break; } temp1=temp1->next; temp2=(temp2->next)->next; X=1; } } if(X==0) { return 0; } else { return 1; } } void Print(Node *head) {
  • 13. Node *temp = head; while(temp!= NULL) { cout<data<< " --> "; temp=temp->next; } cout<< "NULL"; } void ReversePrint(Node *head) { Node *temp1 = head; Node *tail = NULL; Node *head1= new Node; if(head!=NULL) { while(head!=NULL) { head1=head; temp1=temp1->next; head->next=tail; tail=head; head=temp1; } Node *temp=head1; while(temp!= NULL) { cout<data<< " "; temp=temp->next; } } } int main() { int data;
  • 14. Node *head=NULL; int H; cout<< "No. of Node Insertion at Head: "; cin>>H; while(H>0) { cin>>data; head=Insert_atHead(head, data); H--; } int T; cout<< "No. of Node Insertion at Tail: "; cin>>T; while(T>0) { cin>>data; Insert_atTail(head,data); T--; } int P; cout<< " "; cout<< "Add Node at Position: "; cin>>P; cout<< " "; cout<< "data: "; cin>>data; Insert_atPosition(head,data,P); cout<< " "; cout<< "Delete Node at Position: "; cin>>P; Delete(head,P); cout<< " "; Print(head); Reverse_LinkedList(head); head=tail; cout<< " ";
  • 15. Print(head); cout<< " "; cout<< "Size of LinkedList: "<