Write a C++ code to insert a node to the left of the node p in the double linked list shown below. (Each node has three fields: an data field that contains the information, and next and prev fields that contains pointers to nodes on either side. Ex、p->prev represents the address of the node to the left of node p) 2. Ty Dlist https://d2vlcm61l7u1fs.cloudfront.net/media%2F8af%2F8afb98e7-5957-48fd-a03b-332fe0d3ee79%2FphpeAn8OQ.png

CPP Function for insert :
void insert (struct node *head,struct node *p,int newData)
{
struct node *temp = head;
struct node *previous = tail;
struct node *newNode = (struct node *)malloc(sizeof(struct node));
newNode->data = newData;
while(1)
{
if(temp==p)
{
previous->next = newNode;
newNode->prev = previous;
newNode->next = p;
p->prev = newNode;
return ;
}
else
temp=temp->next;
if(temp==head)
{
cout
 
“Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!”

What Students Are Saying About Us

.......... Customer ID: 12*** | Rating: ⭐⭐⭐⭐⭐
"Honestly, I was afraid to send my paper to you, but splendidwritings.com proved they are a trustworthy service. My essay was done in less than a day, and I received a brilliant piece. I didn’t even believe it was my essay at first 🙂 Great job, thank you!"

.......... Customer ID: 14***| Rating: ⭐⭐⭐⭐⭐
"The company has some nice prices and good content. I ordered a term paper here and got a very good one. I'll keep ordering from this website."

"Order a Custom Paper on Similar Assignment! No Plagiarism! Enjoy 20% Discount"