Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include using namespace std; struct Node { int data; struct Node * next; } ; Node * push ( Node * top , int data
#include using namespace std; struct Node int data; struct Node next; ; Node pushNode top int data Node newNode new Node; newNodedata data; newNodenext NULL; if top NULL top newNode; else newNodenext top; top newNode; return top; int topNode top return topdata; int popNode top if top NULL Node temp top; int x topdata; or int x temp data; top topnext; delete temp; return x; else return ; void printStackNode top iftop NULL Node cur top; while cur NULL cout curdata ; cur curnext; cout endl; Node valueCheckNode stackTop return stackTop; int main struct Node myStackTop NULL; myStackTop pushmyStackTop; myStackTop pushmyStackTop; myStackTop pushmyStackTop; myStackTop pushmyStackTop; myStackTop pushmyStackTop; printStackmyStackTop; myStackTop valueCheckmyStackTop; printStackmyStackTop; return ;
#include
using namespace std;
struct Node
int data;
struct Node next;
;
Node pushNode top int data
Node newNode new Node;
newNodedata data;
newNodenext NULL;
if top NULL
top newNode;
else
newNodenext top;
top newNode;
return top;
int topNode top return topdata;
int popNode top
if top NULL
Node temp top;
int x topdata; or int x temp data;
top topnext;
delete temp;
return x;
else
return ;
void printStackNode top
iftop NULL
Node cur top;
while cur NULL
cout curdata ;
cur curnext;
cout endl;
Node valueCheckNode stackTop
return stackTop;
int main
struct Node myStackTop NULL;
myStackTop pushmyStackTop;
myStackTop pushmyStackTop;
myStackTop pushmyStackTop;
myStackTop pushmyStackTop;
myStackTop pushmyStackTop;
printStackmyStackTop;
myStackTop valueCheckmyStackTop;
printStackmyStackTop;
return ;
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