Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm trying to add five functions to my code below to insert a node to the front of my linked list, the back of my

I'm trying to add five functions to my code below to insert a node to the front of my linked list, the back of my linked list, delete from front of linked list, delete from back of linked list, and a print function to print results using a similar function to this for each one:

image text in transcribed

CODE:

#include

using namespace std;

struct nodeType

{

int info;

nodeType *link;

};

void createList(nodeType*& first, nodeType*& last);

void printList(nodeType*& first);

int main()

{

nodeType *first, *last;

int num;

createList(first, last);

printList(first);

system("PAUSE");

return 0;

}

void createList(nodeType*& first, nodeType*& last)

{

int number;

nodeType *newNode;

first = NULL;

last = NULL;

cout

cin>>number;

cout

while (number != -999)

{

newNode = new nodeType; // create new node

newNode->info = number;

newNode->link = NULL;

if (first == NULL)

{

first = newNode;

last = newNode;

}

else

{

last->link = newNode;

last = newNode;

}

cout

cin>>number;

cout

} // end of while-loop

} // end of build list function

void printList(nodeType*& first)

{

cout

nodeType *current;

current = new nodeType;

current = first;

while (current != NULL)

{

cout info

current = current->link;

}

}

void front int n) node *tmpnew node; tmp -data-n; tmp -> nexthead; head -tmp

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions