Question: This program implements insertion and display functions of a pointer based two-way linked List. make some alterations or use this program to perform following tasks

This program implements insertion and display functions of a pointer based two-way linked List.

make some alterations or use this program to perform following tasks in C++.

1. Write a function to insert a new node at front of doubly linked list. (at head) 2. Write a function to print numbers in doubly linked list in reverse order. 3. Write a function to insert a new node after a node having certain value in a pointer based doubly list. 4. Write a function to delete a node having certain value from a pointer based linked list. 5. Write a function to search maximum value from a pointer based doubly linked list.

#include #include using namespace std; void addItem(int d); void display(); struct Node{ int data; Node* next; Node* prev; }; Node *first=NULL,*last=NULL; int main() { addItem(2); addItem(84); addItem(6); display(); getch(); return 0; } void display() { Node* ptrNew = first; while(ptrNew != NULL) { cout<data<<" "; ptrNew = ptrNew->next; } cout<data = n; ptrNew->next = NULL; ptrNew->prev = NULL; if (first==NULL){ first = ptrNew; last = ptrNew; } else { last->next = ptrNew; ptrNew->prev=last; last = ptrNew; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!