Question: Consider a doubly-linked list with several nodes, where pointer first points to the first node in the list and pointer last points to the last

Consider a doubly-linked list with several nodes, where pointer first points to the first node in the list and pointer last points to the last node in the list. Which set of statements can create a new node storing the same value that is stored in the first node, and place the new node at the end of the list? Assume there are at least two nodes in the list and also assume that the count will be incremented. Example: List is: 4 5 8 3 => statement executes => List becomes: 4 5 8 34 List is: 9 4 => statement executes => List becomes: 949 List is: 1 2 3 4 5 6 7 => statement executes => List becomes: 1 2 3 4 5 6 71 A last - last->getNext(); last->set Next (new Node(first->getData(), last, nullptr)); Blast->setNext(new Node(first->getData(), last, nullptr)); last = last->getNext(); clast = last->getNext(); last->set Next (new Node(first->getNext()->getData(), last, nullptr)); D. last->setNext (new Node(first->getNext()->getData(), last, nullptr)); last = last->getNext(); E last->getNext()->setNext (new Node(first->getData(), last, nullptr)); last = last->getNext(); E last = last->getNext(); last->getNext()->setNext(new Node(first->getData(), last, nullptr))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
