Question: DoubleNode -ItemType item; -Node* next; -Node* previous; -headPtr* next; +DoubleNode(); +DoubleNode(const ItemType& anItem); +DoubleNode(const ItemType& anItem), Node* nextNodePtr; +DoubleNode(const ItemType& anItem), Node* previousNodePtr; +void setItem(const

DoubleNode

-ItemType item; -Node* next; -Node* previous; -headPtr* next;
+DoubleNode(); +DoubleNode(const ItemType& anItem); +DoubleNode(const ItemType& anItem), Node* nextNodePtr; +DoubleNode(const ItemType& anItem), Node* previousNodePtr; +void setItem(const ItemType& anItem); +void setNext(DoubleNode* nextNodePtr); +void setPrevious(DoubleNode* previousNodePtr); +ItemType getItem() const: +getPrevious() const : Node* +getNext() const : Node* +Node* getNext() const; +getData()
Pseudocode operations are below for constructor, get, and set I tried to follow Listing 4-1 name usage. Constructor operation is below: Node() : next(nullptr), previous(nullptr) Node(const ItemType& anItem) : previous(nullptr), item(anItem), next(nullptr) Node(const ItemType& anItem), Node* previousNodePtr, Node* nextNodePtr : item(anItem), previous( previousNodePtr), next(nextNodePtr)
Get operation is below: Node* Node::getPrevious() const {return previous;} ItemType Node::getItem() const {return item;} Node* Node::getNext() const {return next;} 
Set operation is below: setPrevious(Node* previousNodePtr) {previous = previousNodePtr;} setItem(const ItemType& anItem) {item = anItem;} setNext(Node* nextNodePtr) {next = nextNodePtr;} 

Define a class DoublyLinkedBag that implements the ADT bag by using a doubly linked chain, as shown in Figure 4-9. Use the class of node .Demonstrate your double linked list implementation in a main function. Tips: Unlike the previous assignment (with arrays) we are not using integers as our data - but the ADT bag, which uses templates. It would be best to implement the ADT linked based implementation of bag first. This majority of this code is done for you in the textbook. Then simply modify the LinkedBag code to handle a double linked list.

 DoubleNode -ItemType item; -Node* next; -Node* previous; -headPtr* next; +DoubleNode(); +DoubleNode(const

  • Inputs
    • Modification of the Node class: Constructor/descructor for the new node (w/ a next and prev pointers)
    • Modification of the Node class: addition of setPrev and getPrev Functions
  • Processing
    • Modification of the LinkedBag class: constructors and destructors
    • Modification of the LinkedBag class: add and remove
  • Output
    • main.cpp demonstrates the initialization and destruction of a double linked list.
    • main.cpp demonstrates an addition and removal from the double linked list.

No asking of shallow or deep code, you have everything you needed now is time to implement the code.

Able..Ba Baker...JonesSmith. Wilson headPtr Able..Ba Baker...JonesSmith. Wilson headPtr

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!