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.
- 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 headPtrStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started