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...

Sometimes known as a “logic bomb”, the __________ is the event or condition that determines when the payload is activated or delivered.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Integration Services is the core service component of SQL Server 2012.

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

Computer Science & Information Technology

Which type of software helps protect against viruses that are attached to e-mail?

A. Firewall software B. Antivirus software C. Windows Defender D. Hardware firewall

Computer Science & Information Technology

Describe each cost classification and include two examples.

What will be an ideal response?

Computer Science & Information Technology