Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Note: you should bring the solution by hand to the office, using hand writing on A 4 pages. Use the following code for tracing the
Note: you should bring the solution by hand to the office, using hand writing on pages.
Use the following code for tracing the contents of the linked list implementation, Note draw the contents
step by step as we declared in the lecture.
a Please insert the following character values and then insert them in reverse order
Notice the resulting word
b And then draw a new graph for the following characters
Inserting at the beginning of a linked chain
Hint: see the following figure
in c
can i get a graph or drawn figure showing the code drawn for this
#include
using namespace std;
Definition of the Node struct
template
struct Node
ItemType item; A data item
Node next; Pointer to next node
;
Definition of the LinkedBag class
template
class LinkedBag
private:
Node headPtr; Pointer to the first node
int itemCount; Current count of list items
public:
Default constructor
LinkedBag : headPtrnullptr itemCount
Member function to add a new node at the beginning of the list
bool addconst ItemType& newEntry
Node newNodePtr new Node;
newNodePtritem newEntry;
newNodePtrnext headPtr; New node points to chain
headPtr newNodePtr; New node is now first node
itemCount;
return true;
Member function to display items from the linked list
void display const
Node currentPtr headPtr;
while currentPtr nullptr
cout currentPtritem ;
currentPtr currentPtrnext;
cout "nullptr
;
Destructor to clear the linked list
~LinkedBag
clear;
Member function to clear the linked list
void clear
Node nodeToDeletePtr headPtr;
while headPtr nullptr
headPtr headPtrnext;
delete nodeToDeletePtr;
nodeToDeletePtr headPtr;
itemCount ;
;
int main
Example of using LinkedBag with char data type
LinkedBag bag;
bag.addp;
bag.adda;
bag.addl;
bag.adda;
bag.addc;
bag.adde;
cout "Linked list after adding characters: ;
bag.display; Displaying the linked list
return ;
i need it drawn based on the questions
like the image i have provided for the words palace ecalap and referral
Step 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