Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Do not change anything in the supplied Ch16_Ex5_MainProgram.cpp except to add documentation and your name . Please use the file names listed below since

C++

Do not change anything in the supplied Ch16_Ex5_MainProgram.cpp except to add documentation and your name.

Please use the file names listed below since your file will have the following components:

Ch16_Ex5_MainProgram.cpp - given file //22 34 56 4 19 2 89 90 0 14 32 88 125 56 11 43 55 -999

#include #include "unorderedLinkedList.h"

using namespace std; int main() { unorderedLinkedList list, subList; int num;

cout << "Enter numbers ending with -999" << endl; cin >> num;

while (num != -999) { list.insertLast(num); cin >> num; }

cout << endl;

cout << "List: "; list.print(); cout << endl; cout << "Length of the list: " << list.length() << endl;

list.divideMid(subList);

cout << "Lists after splitting list" << endl;

cout << "list: "; list.print(); cout << endl; cout << "Length of the list: " << list.length() << endl;

cout << "sublist: "; subList.print(); cout << endl; cout << "Length of subList: " << subList.length() << endl; system("pause"); return 0; }

linkedList.h unorderedLinkedList.h

Dividing a linked list into two sublists of almost equal sizes:Add the operation divideMid to the class linkedListType as follows:

void divideMid(linkedListType &sublist); //This operation divides the given list into two sublists //of (almost) equal sizes. //Postcondition: first points to the first node and last // points to the last node of the first // sublist. // sublist.first points to the first node // and sublist.last points to the last node // of the second sublist. Consider the following statements:

unorderedLinkedList myList; unorderedLinkedList subList;

Suppose myList points to the list with elements 34 65 27 89 12 (in this order). The statement:

myList.divideMid(subList);

divides myList into two sublists: myList points to the list with the elements 34 65 27, and subList points to the sublist with the elements 89 12.

Write the definition of the function template to implement the operation divideMid. Also, write a program to test your function.

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

Students also viewed these Databases questions