Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include #include using namespace std; struct node { int data; node * next; } ; void insertN ( node * &head, node * &displayPtr, int
#include
#include
using namespace std;
struct node
int data;
node
next;
;
void insertN
node
&head, node
&displayPtr, int data
node
pnode;
pnode
new node;
if
pnode
NULL
cout
"Unable to locate node"
data
data;
pnode
next
NULL;
if
head
NULL && displayPtr
NULL
head
pnode;
displayPtr
pnode;
else
head
next
pnode;
head
pnode;
void displayN
node
displayPtr
node
ptr
displayPtr;
while
ptr
NULL
cout
ptr
data;
if
ptr
next
NULL
cout
;
ptr
ptr
next;
cout
endl;
return;
int main
node
head
NULL;
node
displayPtr
NULL;
insertN
head
displayPtr
;
insertN
head
displayPtr
;
insertN
head
displayPtr
;
cout
"Nodes in linked list."
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