Suppose that newName contains a name that you want to delete from the circular d
ID: 3657904 • Letter: S
Question
Suppose that newName contains a name that you want to delete from the circular doubly linked list with a dummy head node. Write some C++ statements that delete the node containing newName.Explanation / Answer
struct node{ node* next; node* prev; int data; }; node*head =NULL; void addNode(int n) { node*newNode = new node; newNode->data = n; if(!head) { head = newNode; head.next = head.previous = NULL; } else { node*currentNode; for( currrentNode = head;currentNode->next && (currentNode->next!=head);currentNode = currentNode->next){} currentNode->next = newNode; newNode->previous = currentNode; newNode->next = head;//complete the circle }
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.