Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this problem please Problem 1. (max 40 points) The templated class SortedList was extended by adding a new member function mergeLists

I need help with this problem please

image text in transcribed
Problem 1. (max 40 points) The templated class SortedList was extended by adding a new member function mergeLists the prototype of which is given below with respective precondition and postcondition // File SortedList.h: Header file for Sorted List ADT. // Class is templated. template struct NodeType Item Type info; NodeType* next; template class SortedList public: SortedList( ); // Class constructor ~SortedList( ); // Class destructor bool full( ) const; int lengthIs ( const; void makeEmpty( ); void retrieveltem(Item Typed item, bool& found); void insertItem (Item Type item); void deleteItem(Item Type item); void resetList(; void getNextItem(ItemTyped); void print( ); /* Precondition: the current object and object list are sorted. Current object is a unique list: no repetition of elements. Object list is a unique list: no repetition of elements. Assume that current list and object list might have the same elements. */ /* Postcondition: result is a sorted list that contains all elements of the current object and object list. Result is a unique list: no repetition of elements */ . . . . .. mergeLists( . . . . . . . . ) private: NodeType * listData; int length; NodeType * currentPos; // templated definitions of member functions + the definition of the new member function mergeLists( ) // Class is templated. #endif N a) Write the prototype (5 points) and the templated definition (15 points) of new member function mergeLists (max 20 points) b) Write a test program which uses the new member function mergeLists and some of the member functions of SortedLists class. Create 6 objects of class SortedList where 2 of them store integers into info part; the next 2 store doubles, and the last 2 store char; each object must have different length where the length varies between 4 and 7 . Output should be very detailed having not less than 25 - 30 lines and should be submitted as a snapshot (.png or .jpeg). (max 10 points) for correct test program + successful compilation + output (max 10 points) with prespecified number of statements; otherwise 0 points) Requirements for new member function mergeLists: Use the .h file from pp. 1 of this lab and the templated class SortedList.h given in this lab. Do not change the name of the new member function mergeLists. Use only private data members of the templated class SortedList based on linked nodes. Do not change the private section of templated class SortedList based on linked nodes. Do not change any given identifier. Submission: One .h file, one .cpp (driver) file and one output (a snapshot). Create not less than 6 objects of class Unsorted List. Output should be very detailed having not less than 18-20 lines. Files in .doc or pdf format will be completely ignored regardless if they are correct or not. (manual writing of files above will not be accepted as well as files copied and pasted into a doc or pdf document : output should be taken as a snapshot. Only output could be saved as an image file and pasted into a doc file )

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions