Question: /* * This file contains all the functions that are called in lab09.cpp * Please note the use of static type here for the void

/* * This file contains all the functions that are called in lab09.cpp * Please note the use of static type here for the void functions. Don't worry about its general use. * For this project, we are using it to aid in easier compilation of the multiple files. * There is no need to delve into it any further than that... */ #include "lab09_headers.h" // Used in the function createLL() // This function is given to you correctly - there is no need to change it static void h_insert(LinkNodePtr& head, string nom, int num) { LinkNodePtr tmp_ptr; tmp_ptr = new LinkNode; tmp_ptr->name = nom; tmp_ptr->number = num; tmp_ptr->link = head; head = tmp_ptr; } static void createLL(LinkNodePtr& h) { // Incomplete function - student must complete string nom = ""; int num; while(0) // THIS IS A STUB { cout << "Enter name, then a number. To quit, enter 0 for the name AND 0 for the number: "; cin >> nom >> num; // Incomplete code here... // At some point, you call: h_insert(h, nom, num); } } static void reverseLL(LinkNodePtr& h) { // Incomplete function - student must complete cout << "reverseLL "; // THIS IS A STUB } static void findMax(LinkNodePtr h) { // Incomplete function - student must complete int max(0); cout << "Largest number in the list is: " << max << endl; } static void findMin(LinkNodePtr h) { // Incomplete function - student must complete int min(0); cout << "Smallest number in the list is: " << min << endl; } static void insertNodeAfter(LinkNodePtr h) { // Incomplete function - student must complete cout << "insertNodeAfter "; // THIS IS A STUB } static void printLL(LinkNodePtr h) { // Incomplete function - student must complete cout << "printLL "; // THIS IS A STUB } 

a) createLL and h_insert: createLL() is the main one of these 2 (i.e. it calls h_insert). It takes the head link (which is, at first, a NULL pointer) and starts adding nodes to it using another function called h_insert(). h_insert() is actually all defined for you and you do not need to edit it further. The program asks the user to: Enter name, then a number. To quit, enter 0 for the name AND 0 for the number:

The user then enters two inputs via cin - a name (string) and an integer number. These two variables, along with the header link, get passed on to h_insert(). This happens in a loop until 0 0 are entered.

b) reverseLL: Takes the head link and proceeds to reverse the links of the LL created by createLL(). Think carefully about how to implement this. HINT: Define links that are about the current node youre looking at, as well as what the next node is and what the previous node is.

c) findMax and findMin: These functions go thru the LL and respectively print out the largest and smallest integers in the number field that they find.

d) insertNodeAfter: Takes the head link as input. It asks the user for a node position to insert a new node after that position, by asking: Enter node position to insert new node after (enter negative number to exit): . Node positions START with the number 0. The function should then:

Quit (return) if a negative position is given.

Otherwise, it should:

Determine how many positions (i.e. how many nodes) exist in the LL.

If the position given by the user is too big, then the function should say: Position entered is illegal. Nothing inserted. (with a newline) and quit (return).

Otherwise, it should:

Ask the user for the data (i.e. name and number) for the new node by asking: Enter data (name, then number):

Create a new node with this data and (the trickiest part) insert it in the LL.

e) printLL: Takes the head link and prints out all the nodes data as follows:

Printing the list: Node #0: ,  Node #1: ,  Node #2: ...etc... 

Please help fill in the functions of this program

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!