Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

. Form a model of double-linked list: a) using pointer tail to last element; b)

ID: 1947504 • Letter: #

Question

. Form a model of double-linked list:
a) using pointer tail to last element;
b) without using pointer tail to last element;
c) developing circular list,
make a description of it and develop list processing operation Insert to add a new element:
a) in the beginning of list;
b) in the end of list;
c) after the i-th element;
d) before i-th element.

Explanation / Answer

#include #include #include using namespace std; struct d_node { int data; d_node *nxt; d_node *prv; }; d_node *current=NULL; d_node *temp1, *temp2; void insert_left(); void insert_right(); void main() { current = new d_node; current->data = 30; current->nxt=NULL; current->prv=NULL; insert_right(); getch(); } void insert_right() { for(int i=1; idata=15+i; temp1->nxt=NULL; temp1->prv=NULL; temp2=current; while(temp2->nxt!=NULL) { temp2=temp2->nxt; } temp2->nxt = temp1; temp1->prv = temp2; } } void insert_left() { for(int i=1; idata=15-i; temp1->nxt=NULL; temp1->prv=NULL; temp2=current; while(temp2->prv!=NULL) { temp2=temp2->prv; } temp2->prv = temp1; temp1->nxt = temp2; } }