Question: Use the following declaration for a singly linked list:- struct node { int data; node *next; }; The following diagram shows the structure of the

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:-

A. 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. (5 Points)

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. (6 Points)

void InsertNode(node *p, int key)

C. Write a function that will remove the last node from the list. (6 Points)

Use the function declaration below:-

void RemoveLastNode(node *p)

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!