.CPP File Code
using namespace std; #include <stdlib.h> #include <iostream> struct StudentDetail{ string name; string vuid; }; //class Node* head; class Node{ struct StudentDetail newStd; class Node* next; class Node* prev; void Set(string name,string vuid) { newStd.name=name; newStd.vuid=vuid; } Node Get() { } void setNext(string name,string vuid){ if(next==NULL) { } else { class Node* newNode= new Node(); newStd.name=name; newStd.vuid=vuid; newNode->next= newNode; } } string getNext() { next; } void setPrev(string name,string vuid){ if(next==NULL) { } else { class Node* newNode= new Node(); newStd.name=name; newStd.vuid=vuid; newNode->next= newNode; } } string getPrev() { prev; } }; class DoublyLinkedList{ public: struct StudentDetail newStd; class DoublyLinkedList* headPtr; class DoublyLinkedList* curPtr; class DoublyLinkedList* nextPtr; int size; //dfdf class DoublyLinkedList* headDlinkList=NULL; void addAtBegining(string vuid, string name) { class DoublyLinkedList* dNode= new DoublyLinkedList(); dNode->newStd.vuid=vuid; dNode->newStd.name=name; dNode->nextPtr=headDlinkList; headDlinkList= dNode; dNode->curPtr=dNode; } void addAtEnd(string vuid, string name) { class DoublyLinkedList* dNode= new DoublyLinkedList(); dNode->newStd.vuid=vuid; dNode->newStd.name=name; dNode->nextPtr=headDlinkList; headDlinkList= dNode; dNode->curPtr=dNode; } void delNode() { class DoublyLinkedList* temp1=curPtr; class DoublyLinkedList* temp2= temp1; temp1->nextPtr= temp2->nextPtr; free(temp2); } void print() { class DoublyLinkedList* temp= headDlinkList; while(temp!=NULL) { cout<<temp->newStd.vuid<<" "<<temp->newStd.name<<endl; temp= temp->nextPtr; } } }; int main() { string vuid,name; cout<<"Add your vuID and Name at First Position "<<endl; cout<<"_ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _"<<endl; DoublyLinkedList dlist1; cin>>vuid; cin>>name; dlist1.addAtBegining(vuid,name); dlist1.print(); cout<<"Insertion At Beginning in doubly Link List "<<endl; cout<<"_ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _"<<endl; cin>>vuid; cin>>name; dlist1.addAtBegining(vuid,name); dlist1.print(); cout<<"Insertion At End in doubly Link List "<<endl; cout<<"_ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _"<<endl; cin>>vuid; cin>>name; dlist1.addAtEnd(vuid,name); dlist1.print(); cout<<"Deletion of Current Node (Last Node) "<<endl; cout<<"_ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _"<<endl; dlist1.delNode(); dlist1.print(); }ZOOI620 Assignment 6 Solution and Discussion


100% Off on Your FEE Join US! Ask Me How?


