Question: Create the new Node and initialize the flelds of class Node ( data and next ) update the head, tail and count accordingly Hint: To

Create the new Node and initialize the flelds of class Node (data and next)
update the head, tail and count accordingly
Hint: To update head and tail properly, You have to consider two scenarios:
If there is no element in the stack and this is the first one going to the stack
If there is another head in the stack
1
loid LLStack:apush(string s)
Node* nemilede = new Node(s):
if (count =0 f
head = nemilodes
tail = nemilodes
nemillode-snext = nullptrs
3
elsed
nemiode-snext = heads
head = nemilodes
3
countst+3
3
/*
First, Check if the stack is empty or not. If not, update the head, tail and count accordingly.
"Don't forget to release memory using delete
Hint: To update head and tail properly, You should consider two different scenarlos:
If LLStack has more than one element
If LLStack has exactly one element
%
void LLStacks:pop()
{
if count =0}
returns
3
if (head =-tan x
dellete heads
head = nullptrs
tall = nullptes
3
elsed
Node retip = head-snexts
delete heads
head = temps
3
count --8
}
OUTPUT
DEBUG CONSOLE
TERMINA
PORTS
COMMENTS
CPPP:25; FAILED:
knomin expression after the reported line}
a fatal error conditions
5EV - Seguentation violation signal
Rases: 2
1 failled
Clons: 2|1| passed I 1 fatled
 Create the new Node and initialize the flelds of class Node

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!