Question
need help:( Use the following declaration for a singly linked list:- struct node { int data; node *next; }; The following diagram shows the structure
need help:(
Use the following declaration for a singly linked list:- struct node { int data; node *next; }; The following diagram shows the structure of the singly linked list:
5 as the head, 4, 3 , 2, 1
Write C++ codes to create a linked list that has the data and a Head pointer pointing to the first node as shown in the diagram above. Create the four nodes and a pointer. Link the four nodes as in the diagram.
B. Write a function that will insert a node at the end of the list. Use the function declaration given below. The function takes input a pointer to the list and data.
void InsertNode(node *p, int key)
C. Write a function that will remove the last node from the list.
Use the function declaration below:- void RemoveLastNode(node *p)
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