Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

  • 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions

Question

25.0 m C B A 52.0 m 65.0 m

Answered: 1 week ago

Question

explain the concept of strategy formulation

Answered: 1 week ago