Revise the method clearso that it calls a recursive method to deallocatethe nodes in the chain.

What will be an ideal response?

```
template
void LinkedBag::clear()
{
deallocate(headPtr);
headPtr = nullptr;
itemCount = 0;
} // end clear
// Private method: Deallocates all nodes assigned to the bag.
template
voidLinkedBag::deallocate(Node* nextNodePtr)
{
if (nextNodePtr != nullptr)
{
Node* nodeToDeletePtr = nextNodePtr;
nextNodePtr = nextNodePtr->getNext();
delete nodeToDeletePtr;
deallocate(nextNodePtr);
} // end if
} // end deallocate

```

Computer Science & Information Technology

You might also like to view...

Which of the following would be sent to an SNMP network management system in the event that a failure or predefined threshold was crossed?

A. SNMP trap B. History log C. System log D. SNMP agent

Computer Science & Information Technology

When working with layers, it is important to make sure you know which layer you are editing by looking at the active layer on the Layers panel.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology