Question
Using the c++ code below create new class of student with studentID,StudentName,CGPA to add the student in the doubly Linked list aswell a function to
Using the c++ code below create new class of student with studentID,StudentName,CGPA to add the student in the doubly Linked list aswell a function to delete and replace and a function to check the duplicated added ID and display the count of duplicated number for each student and show the duplicated ID's in the doubly linked:
(use duoubly linked concept as code below)
#include
using namespace std;
class DoublyLL
{
private:
struct node
{
int data;
node *next;
node *pre;
};
node *head;
node *tail;
public:
DoublyLL()
{
head = NULL;
tail = NULL;
}
void addToTail(int number)
{
node *n = new node();
n->next = NULL;
n->pre = NULL;
n->data = number;
if (tail == NULL)
{
head = n;
tail = n;
cout << number << " is added to the tail" << endl;
}
else
{
tail->next = n;
n->pre = tail;
tail = n;
cout << number << " is added to the list" << endl;
}
}
void displayForward()
{
cout << "Printing in Forward order" << endl;
node *temp = head;
while (temp != NULL)
{
cout << temp->data << " ";
temp = temp->next;
}
cout << endl;
}
void displayReverse()
{
cout << "Printing in Reverse order" << endl;
node *temp = tail;
while (temp != NULL)
{
cout << temp->data << " ";
temp = temp->pre;
}
cout << endl;
}
};
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started