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

I'm trying to add five functions to my code below to insert

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

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!