Question: Below is the code for the problem. Complete it as necessary. #include #include using namespace std; struct Node { int data; Node* next; }; const

 Below is the code for the problem. Complete it as necessary.

Below is the code for the problem. Complete it as necessary.

#include

#include

using namespace std;

struct Node

{

int data;

Node* next;

};

const string FILENAME = "/home/fac/sreeder/class/cs2430/lab2.dat";

void insertInOrder(Node*& h, int d);

// inserts d into h in numerical order

// post: h may be changed

void printList(Node* h);

// prints all data on h to the screen in a column

void delList(Node*& h);

// post: each node of h deleted

int main()

{

Node* head = nullptr;

ifstream inFile;

int num;

inFile.open(FILENAME);

if (inFile.fail()){

cout

cin.get();

}

while (inFile >> num)

insertInOrder(head, num);

inFile.close();

cout

printList(head);

cout

delList(head);

return 0;

}

void insertInOrder(Node*& h, int d)

{

// complete this function

}

void printList(Node* h)

{

// complete this function

}

void delList(Node*& h)

{

// complete this function

}

lab2.dat Write a short program in C++ that accomplishes the following: 1) Contains a node for a linked list that can store a single piece of integer data, along 17 78 with the pointer to the next node. 2) Reads the file "lab2.dat" from the class - create a constant string for this 3) While reading the file, inserts the integers into a linked list in numerical order (from smallest to largest). Be sure to close the file when you are done reading. 4) Prints the finished list in a column to the screen. 5) Deletes all nodes in the list before ending the program. Three functions are recommended: "insert in order", "prit", "delete list". There are no 137 0 45 32 1 6 classes to be created for this assignment. 12 19 78 86 4

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!