Consider a linked chain of three nodes, such that each node contains a string.The first node contains "A", the second node contains "B", and the third node contains "C".

a. Write C++ statements that create the described linked chain. Beginning with a head pointer headPtr that contains nullptr, create and attach a node for "C", then create and attach a node for "B", and finally create and attach a node for "A".
b. Repeat part a, but instead create and attach nodes in the order "A", "B", "C".

```
// Part a: Create nodes for C, B, and A; insert nodes at beginning of chain.
headPtr = new Node("C");
Node* newNodePtr = new Node("B");
newNodePtr->setNext(headPtr);
headPtr = newNodePtr;
newNodePtr = new Node("A");
newNodePtr->setNext(headPtr);
headPtr = newNodePtr;
// Part b: Create nodes for A, B, and C; insert nodes at end of chain.
headPtr = new Node("A");
Node* newNodePtr = new Node("B");
headPtr->setNext(newNodePtr);
Node* lastNodePtr = newNodePtr;
newNodePtr = new Node("C");
lastNodePtr->setNext(newNodePtr);

```

Computer Science & Information Technology

You might also like to view...

An announcements ________ is used to inform SharePoint site users about upcoming events, news, or activities

A) item B) list C) zone D) page

Computer Science & Information Technology

What is the best definition of privileged information?

a. Any documents or other material evidence that both parties are privileged to examine. b. Any documents or other material evidence that, while otherwise defined by a discovery motion, may be withheld from evidence due to the nature of the material. c. Any documents or other material evidence that have been identified in a legally obtained electronic discovery order. d. Any documents prepared by an attorney.

Computer Science & Information Technology