SlideShare a Scribd company logo
1 of 12
Download to read offline
Background:
In many applications, the composition of a collection of data items changes over time. Not only
are new data items added and existing ones removed, but data items may be duplicated. A list
data structure is a member of the general category of abstract data types called containers, whose
purpose is to hold other objects. In C++, lists are provided in the Standard Template Library.
However, for this assignment you will design and write your own linked list implementation to
support the ADT operations specified below.
Objective:
Design and implement the specifications for a List Abstract Data Type where the items in the list
are unsorted.
Requirements:
Define a list and develop a set of operations for creating and manipulating a list that satisfies the
list ADT specification.
List ADT Specification
Structure: The list elements are of ItemType. The list has a property called the current position
which designates the position of the last element accessed by GetNextItem during an iteration
through the list. Only ResetList and GetNextItem alter the current position.
Definitions (provided by the user):
MAX_ITEMS: A constant specifying the maximum capacity of items allowed on the list
Item Type: Class encapsulating the type of items in the list
RelationType: An enumeration type that consists of LESS, GREATER, EQUAL
Member function of ItemType that must be included:
RelationType ComparedTo(ItemType Item)
Function: Determines the ordering of two ItemType objects based on their keys
Precondition: Self and item have their key members initialized
Postcondition:
Function value = LESS if the key of self is less than the key of item
= GREATER if the key of self is greater than the key of item
= EQUAL if the keys are equal
Operations (provided by Unsorted List ADT)
Make Empty
Function: Initializes list to empty state
Preconditions: None
Postcondition: List is empty
Boolean IsFull
Function: Determines whether list is full
Preconditions: List has been initialized
Postcondition: Function value = (list is full)
int GetLength
Function: Determines the number of elements in list
Preconditions: List has been initialized
Postcondition: Function value = number of elements in list
ItemType GetItem(Item Typeitem, Boolean& found)
Function: Get list element whose key matches item’s key (if present)
Preconditions: List has been initialized
Key member of item is initialized
Postcondition: If there is an element someItem whose keymatches item’s key, then found =
true and copy of someItemis returned; otherwise found = false and item is returned
List is unchanged
PutItem(ItemType item)
Function: Puts item into list
Preconditions: List has been initialized
List is not full
Item is not in list
Postcondition: Item is in the list
DeleteItem(ItemType item)
Function: Deletes the element whose key matches item’s key
Preconditions: List has been initialized
Postcondition: One and only one element in list has a key matching item’s key
ResetList
Function: Initializes current position for an iteration through the list
Preconditions: List has been initialized
Postcondition: Current position is prior to list
ItemType GetNextItem()
Function: Gets the next element in list
Preconditions: List has been initialized
Current position is defined
Element at current position is not last in list
Postcondition: Current position is updated to next position
Returns a copy of element at current position
UML
The UML diagrams for the linked class UnsortedList are included as an attachment.
Test Run Requirements: Only submit one run that shows a sample client that instantiates a list
object, reads in test data from the listData test file and writes the test results to the
a3testFirstnameLastname file (for FirstnameLastname your Firstname and Lastname).
Grading Criteria:
ItemType class is correctly defined and implemented.
UnsortedType class is correctly defined and implemented.
Program compiles and runs.
Implementation supports the operations given in the ADT functional requirements.
A test driver is included to satisfy the test run demonstration.
A copy of your test run output display is included in an output file named
a3testFirstnameLastname
Be sure to include 6 separate files:
ItemType.h
ItemType.cpp
unsorted.h
unsorted.cpp
listDr.cpp
Solution
//---------------------------ItemType.cpp----------------------------------------------------------------------
-------
#include
#include
#include "ch03-ItemType.h"
using namespace std;
ItemType::ItemType()
{ value = 0;
}
RelationType ItemType::ComparedTo(ItemType otherItem) const
{
if (value < otherItem.value)
return LESS;
else if (value > otherItem.value)
return GREATER;
else return EQUAL;
}
void ItemType::Initialize(int number)
{
value = number;
}
void ItemType::Print() const
{
cout << value;
}
//---------------------------ItemType.h-------------------------------------------------------------------------
----
#include
using namespace std;
#ifndef ITEMTYPE_H
#define ITEMTYPE_H
const int MAX_ITEMS = 25;
enum RelationType {LESS, GREATER, EQUAL};
class ItemType
{
private:
int value;
public:
ItemType();
RelationType ComparedTo(ItemType) const;
void Print() const;
void Initialize(int number);
};
#endif
//---------------------------Unsorted.h--------------------------------------------------------------------------
---
#include "ch03-ItemType.h"
using namespace std;
#ifndef UNSORTEDTYPE_H
#define UNSORTEDTYPE_H
class UnsortedType
{
private:
struct NodeType
{
ItemType info;
NodeType* next;
};
NodeType* listData;
int length;
NodeType* currentPos;
public:
UnsortedType();
~UnsortedType();
void MakeEmpty();
bool IsFull() const;
int GetLength() const;
ItemType GetItem(ItemType& item, bool& found);
void PutItem(ItemType item);
void DeleteItem(ItemType item);
void ResetList();
ItemType GetNextItem();
void SplitList(ItemType item, UnsortedType &list1, UnsortedType &list2);
};
#endif
//---------------------------Unsorted.cpp-----------------------------------------------------------------------
------
#include "hw2-UnsortedType.h"
#include
using namespace std;
UnsortedType::UnsortedType()
{
length = 0;
listData = NULL;
}
UnsortedType::~UnsortedType()
{
NodeType* tempPtr;
while(listData != NULL)
{
tempPtr = listData;
listData = listData->next;
delete tempPtr;
}
}
void UnsortedType::MakeEmpty()
{
NodeType* tempPtr;
while(listData != NULL)
{
tempPtr = listData;
listData = listData->next;
delete tempPtr;
}
length = 0;
}
bool UnsortedType::IsFull() const
{
NodeType* location;
try
{
location = new NodeType;
delete location;
return false;
}
catch(bad_alloc)
{
return true;
}
}
int UnsortedType::GetLength() const
{
return length;
}
void UnsortedType::PutItem(ItemType item)
{
NodeType* location = new NodeType;
location->info = item;
location->next = listData;
listData = location;
length++;
}
ItemType UnsortedType::GetItem(ItemType& item, bool& found)
{
bool moreToSearch;
NodeType* location;
location = listData;
found = false;
moreToSearch = (location != NULL);
while (moreToSearch && !found)
{
switch (item.ComparedTo(location->info))
{
case LESS :
case GREATER : location = location->next;
moreToSearch = (location != NULL);
break;
case EQUAL : found = true;
item = location->info;
break;
}
}
return item;
}
void UnsortedType::DeleteItem(ItemType item)
{
NodeType* location;
NodeType* tempLocation;
location = listData;
if (item.ComparedTo(location->info) == EQUAL)
{
tempLocation = location;
listData = listData->next;
}
else
{
while (!((item.ComparedTo((location->next)->info) == EQUAL)))
location = location->next;
tempLocation = location->next;
location->next = (location->next)->next;
}
delete tempLocation;
length--;
}
void UnsortedType::ResetList()
{
currentPos = NULL;
}
ItemType UnsortedType::GetNextItem()
{
if (currentPos == NULL)
currentPos = listData;
else
currentPos = currentPos->next;
return currentPos->info;
}
void UnsortedType::SplitList(ItemType item, UnsortedType &list1, UnsortedType &list2)
{
ItemType location;
ResetList();
for (int counter = 1, length = GetLength(); counter <= length; counter++)
{
location = GetNextItem();
cout << "Parsing Item: ";
location.Print();
cout << endl;
switch (location.ComparedTo(item))
{
case LESS :
case EQUAL : list1.PutItem(location);
break;
case GREATER : list2.PutItem(location);
break;
};
};
}
//------------------------------------------------listDr.cpp------------------------------------------------------
---
#include
#include
#include
#include "ListDr-UnsortedType.h"
using namespace std;
void PrintList(UnsortedType&);
void SplitList(UnsortedType&, ItemType);
int main()
{
ifstream inFile;
string command;
int number;
ItemType item;
UnsortedType list;
bool found;
int numCommands;
inFile.open("listhw.txt");
if (!inFile)
{
cout << "Unable to open input file - ending program." << endl;
exit(1);
}
inFile >> command;
numCommands = 0;
while (command != "Quit")
{
numCommands++;
cout << "Command " << numCommands << ": " << command << " ";
if (command == "PutItem")
{
inFile >> number;
item.Initialize(number);
list.PutItem(item);
item.Print();
cout << " added to list" << endl;
}
else if (command == "GetItem")
{
inFile >> number;
item.Initialize(number);
item = list.GetItem(item, found);
item.Print();
if (found)
cout << " found in list." << endl;
else
cout << " not in list." << endl;
}
else if (command == "DeleteItem")
{
inFile >> number;
item.Initialize(number);
list.DeleteItem(item);
item.Print();
cout << " deleted from list" << endl;
}
else if (command == "GetLength")
{
cout << "Length of list = " << list.GetLength() << endl;
}
else if (command == "IsFull")
{
if (list.IsFull())
cout << "List is full." << endl;
else
cout << "List is not full." << endl;
}
else if (command == "MakeEmpty")
{ list.MakeEmpty();
cout << "List is empty." << endl;
}
else if (command == "PrintList")
{
cout << "  List values" << endl;
PrintList(list);
}
else if (command == "SplitList")
{
inFile >> number;
item.Initialize(number);
SplitList(list,item);
}
else
cout << command << " is not a valid command." << endl;
inFile >> command;
};
cout << "Testing completed." << endl;
inFile.close();
return 0;
}
//----------------------------------------
// PrintList
// Non-member function to print all items in list
// Pre: list has been initialized
// Post: Each component in list has been written to cout
//----------------------------------------
void PrintList(UnsortedType &list)
{
int length;
ItemType item;
list.ResetList();
length = list.GetLength();
for (int counter = 1; counter <= length; counter++)
{
item = list.GetNextItem();
item.Print();
cout << endl;
}
cout << "Length of list = " << length << endl << endl;
}
void SplitList(UnsortedType &list, ItemType item)
{
UnsortedType list1, list2;
list.SplitList(item,list1,list2);
cout << "The list has been split into two." << endl << endl;
cout << "List 1:" << endl;
PrintList(list1);
cout << "List 2:" << endl;
PrintList(list2);
}

More Related Content

Similar to BackgroundIn many applications, the composition of a collection o.pdf

01-intro_stacks.ppt
01-intro_stacks.ppt01-intro_stacks.ppt
01-intro_stacks.pptsoniya555961
 
Complete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdfComplete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdfrajkumarm401
 
-- Write the compiler used- Visual studio or gcc -- Reminder that your.pdf
-- Write the compiler used- Visual studio or gcc -- Reminder that your.pdf-- Write the compiler used- Visual studio or gcc -- Reminder that your.pdf
-- Write the compiler used- Visual studio or gcc -- Reminder that your.pdfganisyedtrd
 
written in c- please answer the 4 questions and write the functions ba.pdf
written in c- please answer the 4 questions and write the functions ba.pdfwritten in c- please answer the 4 questions and write the functions ba.pdf
written in c- please answer the 4 questions and write the functions ba.pdfsravi07
 
For this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdfFor this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdffashiongallery1
 
Written in C- requires linked lists- Please answer the 4 questions and.pdf
Written in C- requires linked lists- Please answer the 4 questions and.pdfWritten in C- requires linked lists- Please answer the 4 questions and.pdf
Written in C- requires linked lists- Please answer the 4 questions and.pdfsravi07
 
Written in C- requires linked lists- Please answer the 4 questions and (1).pdf
Written in C- requires linked lists- Please answer the 4 questions and (1).pdfWritten in C- requires linked lists- Please answer the 4 questions and (1).pdf
Written in C- requires linked lists- Please answer the 4 questions and (1).pdfsravi07
 
please follow all instructions and answer the inbedded questions- and.pdf
please follow all instructions and answer the inbedded questions- and.pdfplease follow all instructions and answer the inbedded questions- and.pdf
please follow all instructions and answer the inbedded questions- and.pdfIan5L3Allanm
 
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
 The MyLinkedList class used in Listing 24.6 is a one-way directional .docx The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
The MyLinkedList class used in Listing 24.6 is a one-way directional .docxKomlin1
 
2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdfarshin9
 
Please need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdfPlease need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdfnitinarora01
 
Implement the ListArray ADT-Implement the following operations.pdf
Implement the ListArray ADT-Implement the following operations.pdfImplement the ListArray ADT-Implement the following operations.pdf
Implement the ListArray ADT-Implement the following operations.pdfpetercoiffeur18
 
Sorting & Linked Lists
Sorting & Linked ListsSorting & Linked Lists
Sorting & Linked ListsJ.T.A.JONES
 
Using Array Approach, Linked List approach, and Delete Byte Approach.pdf
Using Array Approach, Linked List approach, and Delete Byte Approach.pdfUsing Array Approach, Linked List approach, and Delete Byte Approach.pdf
Using Array Approach, Linked List approach, and Delete Byte Approach.pdffms12345
 
Number 1 I have completed and number 6 is just uploading I .pdf
Number 1 I have completed and number 6 is just uploading I .pdfNumber 1 I have completed and number 6 is just uploading I .pdf
Number 1 I have completed and number 6 is just uploading I .pdfadvancethchnologies
 
#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx
#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx
#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docxajoy21
 

Similar to BackgroundIn many applications, the composition of a collection o.pdf (20)

01-intro_stacks.ppt
01-intro_stacks.ppt01-intro_stacks.ppt
01-intro_stacks.ppt
 
Chapter 5 ds
Chapter 5 dsChapter 5 ds
Chapter 5 ds
 
Adt of lists
Adt of listsAdt of lists
Adt of lists
 
Complete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdfComplete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdf
 
-- Write the compiler used- Visual studio or gcc -- Reminder that your.pdf
-- Write the compiler used- Visual studio or gcc -- Reminder that your.pdf-- Write the compiler used- Visual studio or gcc -- Reminder that your.pdf
-- Write the compiler used- Visual studio or gcc -- Reminder that your.pdf
 
written in c- please answer the 4 questions and write the functions ba.pdf
written in c- please answer the 4 questions and write the functions ba.pdfwritten in c- please answer the 4 questions and write the functions ba.pdf
written in c- please answer the 4 questions and write the functions ba.pdf
 
For this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdfFor this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdf
 
Written in C- requires linked lists- Please answer the 4 questions and.pdf
Written in C- requires linked lists- Please answer the 4 questions and.pdfWritten in C- requires linked lists- Please answer the 4 questions and.pdf
Written in C- requires linked lists- Please answer the 4 questions and.pdf
 
Written in C- requires linked lists- Please answer the 4 questions and (1).pdf
Written in C- requires linked lists- Please answer the 4 questions and (1).pdfWritten in C- requires linked lists- Please answer the 4 questions and (1).pdf
Written in C- requires linked lists- Please answer the 4 questions and (1).pdf
 
please follow all instructions and answer the inbedded questions- and.pdf
please follow all instructions and answer the inbedded questions- and.pdfplease follow all instructions and answer the inbedded questions- and.pdf
please follow all instructions and answer the inbedded questions- and.pdf
 
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
 The MyLinkedList class used in Listing 24.6 is a one-way directional .docx The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
 
2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf
 
Chap10
Chap10Chap10
Chap10
 
Array list(1)
Array list(1)Array list(1)
Array list(1)
 
Please need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdfPlease need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdf
 
Implement the ListArray ADT-Implement the following operations.pdf
Implement the ListArray ADT-Implement the following operations.pdfImplement the ListArray ADT-Implement the following operations.pdf
Implement the ListArray ADT-Implement the following operations.pdf
 
Sorting & Linked Lists
Sorting & Linked ListsSorting & Linked Lists
Sorting & Linked Lists
 
Using Array Approach, Linked List approach, and Delete Byte Approach.pdf
Using Array Approach, Linked List approach, and Delete Byte Approach.pdfUsing Array Approach, Linked List approach, and Delete Byte Approach.pdf
Using Array Approach, Linked List approach, and Delete Byte Approach.pdf
 
Number 1 I have completed and number 6 is just uploading I .pdf
Number 1 I have completed and number 6 is just uploading I .pdfNumber 1 I have completed and number 6 is just uploading I .pdf
Number 1 I have completed and number 6 is just uploading I .pdf
 
#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx
#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx
#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx
 

More from mayorothenguyenhob69

If the sample means are different from the population mean, what do .pdf
If the sample means are different from the population mean, what do .pdfIf the sample means are different from the population mean, what do .pdf
If the sample means are different from the population mean, what do .pdfmayorothenguyenhob69
 
How would you define the Wilcoxon Signed Rank TestSolutionThe.pdf
How would you define the Wilcoxon Signed Rank TestSolutionThe.pdfHow would you define the Wilcoxon Signed Rank TestSolutionThe.pdf
How would you define the Wilcoxon Signed Rank TestSolutionThe.pdfmayorothenguyenhob69
 
How could global climate change affect vector-borne or zoonotic di.pdf
How could global climate change affect vector-borne or zoonotic di.pdfHow could global climate change affect vector-borne or zoonotic di.pdf
How could global climate change affect vector-borne or zoonotic di.pdfmayorothenguyenhob69
 
How Can Sequence Data Be Used to Track Flu Virus Evolution During Pan.pdf
How Can Sequence Data Be Used to Track Flu Virus Evolution During Pan.pdfHow Can Sequence Data Be Used to Track Flu Virus Evolution During Pan.pdf
How Can Sequence Data Be Used to Track Flu Virus Evolution During Pan.pdfmayorothenguyenhob69
 
Far from being primitive, bacteria have evolved until they are i.pdf
Far from being primitive, bacteria have evolved until they are i.pdfFar from being primitive, bacteria have evolved until they are i.pdf
Far from being primitive, bacteria have evolved until they are i.pdfmayorothenguyenhob69
 
E1-1 Reporting Amounts on the Four Basic Financial Statements [LO 1-2.pdf
E1-1 Reporting Amounts on the Four Basic Financial Statements [LO 1-2.pdfE1-1 Reporting Amounts on the Four Basic Financial Statements [LO 1-2.pdf
E1-1 Reporting Amounts on the Four Basic Financial Statements [LO 1-2.pdfmayorothenguyenhob69
 
Do differentiated cells transform into other type of cells How Wha.pdf
Do differentiated cells transform into other type of cells How Wha.pdfDo differentiated cells transform into other type of cells How Wha.pdf
Do differentiated cells transform into other type of cells How Wha.pdfmayorothenguyenhob69
 
Define the terms activity, layout, intent, and AVDSolutionACT.pdf
Define the terms activity, layout, intent, and AVDSolutionACT.pdfDefine the terms activity, layout, intent, and AVDSolutionACT.pdf
Define the terms activity, layout, intent, and AVDSolutionACT.pdfmayorothenguyenhob69
 
Describe the similarities and differences between IPv4 & IPv6.So.pdf
Describe the similarities and differences between IPv4 & IPv6.So.pdfDescribe the similarities and differences between IPv4 & IPv6.So.pdf
Describe the similarities and differences between IPv4 & IPv6.So.pdfmayorothenguyenhob69
 
Compare different sexual and asexual life cycles noting their adapti.pdf
Compare different sexual and asexual life cycles noting their adapti.pdfCompare different sexual and asexual life cycles noting their adapti.pdf
Compare different sexual and asexual life cycles noting their adapti.pdfmayorothenguyenhob69
 
11.25In 2010, there were 117,538,000 households in the United Stat.pdf
11.25In 2010, there were 117,538,000 households in the United Stat.pdf11.25In 2010, there were 117,538,000 households in the United Stat.pdf
11.25In 2010, there were 117,538,000 households in the United Stat.pdfmayorothenguyenhob69
 
Which methodology may be used for detection of incorporated BrdUA.pdf
Which methodology may be used for detection of incorporated BrdUA.pdfWhich methodology may be used for detection of incorporated BrdUA.pdf
Which methodology may be used for detection of incorporated BrdUA.pdfmayorothenguyenhob69
 
Which of the following is a difference between lightweight and heavy.pdf
Which of the following is a difference between lightweight and heavy.pdfWhich of the following is a difference between lightweight and heavy.pdf
Which of the following is a difference between lightweight and heavy.pdfmayorothenguyenhob69
 
What are the common conditions resulting in thrombocytosis Explain .pdf
What are the common conditions resulting in thrombocytosis Explain .pdfWhat are the common conditions resulting in thrombocytosis Explain .pdf
What are the common conditions resulting in thrombocytosis Explain .pdfmayorothenguyenhob69
 
What are some differences between the xylem and the phloem Solu.pdf
What are some differences between the xylem and the phloem  Solu.pdfWhat are some differences between the xylem and the phloem  Solu.pdf
What are some differences between the xylem and the phloem Solu.pdfmayorothenguyenhob69
 
Two families of sloths exist commonly in Central and South America (t.pdf
Two families of sloths exist commonly in Central and South America (t.pdfTwo families of sloths exist commonly in Central and South America (t.pdf
Two families of sloths exist commonly in Central and South America (t.pdfmayorothenguyenhob69
 
Two populations of rats are discovered on nearby islands. Describe t.pdf
Two populations of rats are discovered on nearby islands. Describe t.pdfTwo populations of rats are discovered on nearby islands. Describe t.pdf
Two populations of rats are discovered on nearby islands. Describe t.pdfmayorothenguyenhob69
 
30-32 Nuclear pores permit the passage of chromosomes outward. glu.pdf
30-32 Nuclear pores permit the passage of  chromosomes outward.  glu.pdf30-32 Nuclear pores permit the passage of  chromosomes outward.  glu.pdf
30-32 Nuclear pores permit the passage of chromosomes outward. glu.pdfmayorothenguyenhob69
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfmayorothenguyenhob69
 
B-tree insertion (Draw node) Show the results of inserting the keys .pdf
B-tree insertion (Draw node) Show the results of inserting the keys .pdfB-tree insertion (Draw node) Show the results of inserting the keys .pdf
B-tree insertion (Draw node) Show the results of inserting the keys .pdfmayorothenguyenhob69
 

More from mayorothenguyenhob69 (20)

If the sample means are different from the population mean, what do .pdf
If the sample means are different from the population mean, what do .pdfIf the sample means are different from the population mean, what do .pdf
If the sample means are different from the population mean, what do .pdf
 
How would you define the Wilcoxon Signed Rank TestSolutionThe.pdf
How would you define the Wilcoxon Signed Rank TestSolutionThe.pdfHow would you define the Wilcoxon Signed Rank TestSolutionThe.pdf
How would you define the Wilcoxon Signed Rank TestSolutionThe.pdf
 
How could global climate change affect vector-borne or zoonotic di.pdf
How could global climate change affect vector-borne or zoonotic di.pdfHow could global climate change affect vector-borne or zoonotic di.pdf
How could global climate change affect vector-borne or zoonotic di.pdf
 
How Can Sequence Data Be Used to Track Flu Virus Evolution During Pan.pdf
How Can Sequence Data Be Used to Track Flu Virus Evolution During Pan.pdfHow Can Sequence Data Be Used to Track Flu Virus Evolution During Pan.pdf
How Can Sequence Data Be Used to Track Flu Virus Evolution During Pan.pdf
 
Far from being primitive, bacteria have evolved until they are i.pdf
Far from being primitive, bacteria have evolved until they are i.pdfFar from being primitive, bacteria have evolved until they are i.pdf
Far from being primitive, bacteria have evolved until they are i.pdf
 
E1-1 Reporting Amounts on the Four Basic Financial Statements [LO 1-2.pdf
E1-1 Reporting Amounts on the Four Basic Financial Statements [LO 1-2.pdfE1-1 Reporting Amounts on the Four Basic Financial Statements [LO 1-2.pdf
E1-1 Reporting Amounts on the Four Basic Financial Statements [LO 1-2.pdf
 
Do differentiated cells transform into other type of cells How Wha.pdf
Do differentiated cells transform into other type of cells How Wha.pdfDo differentiated cells transform into other type of cells How Wha.pdf
Do differentiated cells transform into other type of cells How Wha.pdf
 
Define the terms activity, layout, intent, and AVDSolutionACT.pdf
Define the terms activity, layout, intent, and AVDSolutionACT.pdfDefine the terms activity, layout, intent, and AVDSolutionACT.pdf
Define the terms activity, layout, intent, and AVDSolutionACT.pdf
 
Describe the similarities and differences between IPv4 & IPv6.So.pdf
Describe the similarities and differences between IPv4 & IPv6.So.pdfDescribe the similarities and differences between IPv4 & IPv6.So.pdf
Describe the similarities and differences between IPv4 & IPv6.So.pdf
 
Compare different sexual and asexual life cycles noting their adapti.pdf
Compare different sexual and asexual life cycles noting their adapti.pdfCompare different sexual and asexual life cycles noting their adapti.pdf
Compare different sexual and asexual life cycles noting their adapti.pdf
 
11.25In 2010, there were 117,538,000 households in the United Stat.pdf
11.25In 2010, there were 117,538,000 households in the United Stat.pdf11.25In 2010, there were 117,538,000 households in the United Stat.pdf
11.25In 2010, there were 117,538,000 households in the United Stat.pdf
 
Which methodology may be used for detection of incorporated BrdUA.pdf
Which methodology may be used for detection of incorporated BrdUA.pdfWhich methodology may be used for detection of incorporated BrdUA.pdf
Which methodology may be used for detection of incorporated BrdUA.pdf
 
Which of the following is a difference between lightweight and heavy.pdf
Which of the following is a difference between lightweight and heavy.pdfWhich of the following is a difference between lightweight and heavy.pdf
Which of the following is a difference between lightweight and heavy.pdf
 
What are the common conditions resulting in thrombocytosis Explain .pdf
What are the common conditions resulting in thrombocytosis Explain .pdfWhat are the common conditions resulting in thrombocytosis Explain .pdf
What are the common conditions resulting in thrombocytosis Explain .pdf
 
What are some differences between the xylem and the phloem Solu.pdf
What are some differences between the xylem and the phloem  Solu.pdfWhat are some differences between the xylem and the phloem  Solu.pdf
What are some differences between the xylem and the phloem Solu.pdf
 
Two families of sloths exist commonly in Central and South America (t.pdf
Two families of sloths exist commonly in Central and South America (t.pdfTwo families of sloths exist commonly in Central and South America (t.pdf
Two families of sloths exist commonly in Central and South America (t.pdf
 
Two populations of rats are discovered on nearby islands. Describe t.pdf
Two populations of rats are discovered on nearby islands. Describe t.pdfTwo populations of rats are discovered on nearby islands. Describe t.pdf
Two populations of rats are discovered on nearby islands. Describe t.pdf
 
30-32 Nuclear pores permit the passage of chromosomes outward. glu.pdf
30-32 Nuclear pores permit the passage of  chromosomes outward.  glu.pdf30-32 Nuclear pores permit the passage of  chromosomes outward.  glu.pdf
30-32 Nuclear pores permit the passage of chromosomes outward. glu.pdf
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdf
 
B-tree insertion (Draw node) Show the results of inserting the keys .pdf
B-tree insertion (Draw node) Show the results of inserting the keys .pdfB-tree insertion (Draw node) Show the results of inserting the keys .pdf
B-tree insertion (Draw node) Show the results of inserting the keys .pdf
 

Recently uploaded

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 

BackgroundIn many applications, the composition of a collection o.pdf

  • 1. Background: In many applications, the composition of a collection of data items changes over time. Not only are new data items added and existing ones removed, but data items may be duplicated. A list data structure is a member of the general category of abstract data types called containers, whose purpose is to hold other objects. In C++, lists are provided in the Standard Template Library. However, for this assignment you will design and write your own linked list implementation to support the ADT operations specified below. Objective: Design and implement the specifications for a List Abstract Data Type where the items in the list are unsorted. Requirements: Define a list and develop a set of operations for creating and manipulating a list that satisfies the list ADT specification. List ADT Specification Structure: The list elements are of ItemType. The list has a property called the current position which designates the position of the last element accessed by GetNextItem during an iteration through the list. Only ResetList and GetNextItem alter the current position. Definitions (provided by the user): MAX_ITEMS: A constant specifying the maximum capacity of items allowed on the list Item Type: Class encapsulating the type of items in the list RelationType: An enumeration type that consists of LESS, GREATER, EQUAL Member function of ItemType that must be included: RelationType ComparedTo(ItemType Item) Function: Determines the ordering of two ItemType objects based on their keys Precondition: Self and item have their key members initialized Postcondition: Function value = LESS if the key of self is less than the key of item = GREATER if the key of self is greater than the key of item = EQUAL if the keys are equal Operations (provided by Unsorted List ADT) Make Empty Function: Initializes list to empty state Preconditions: None Postcondition: List is empty Boolean IsFull
  • 2. Function: Determines whether list is full Preconditions: List has been initialized Postcondition: Function value = (list is full) int GetLength Function: Determines the number of elements in list Preconditions: List has been initialized Postcondition: Function value = number of elements in list ItemType GetItem(Item Typeitem, Boolean& found) Function: Get list element whose key matches item’s key (if present) Preconditions: List has been initialized Key member of item is initialized Postcondition: If there is an element someItem whose keymatches item’s key, then found = true and copy of someItemis returned; otherwise found = false and item is returned List is unchanged PutItem(ItemType item) Function: Puts item into list Preconditions: List has been initialized List is not full Item is not in list Postcondition: Item is in the list DeleteItem(ItemType item) Function: Deletes the element whose key matches item’s key Preconditions: List has been initialized Postcondition: One and only one element in list has a key matching item’s key ResetList Function: Initializes current position for an iteration through the list Preconditions: List has been initialized Postcondition: Current position is prior to list ItemType GetNextItem() Function: Gets the next element in list Preconditions: List has been initialized Current position is defined Element at current position is not last in list Postcondition: Current position is updated to next position Returns a copy of element at current position UML
  • 3. The UML diagrams for the linked class UnsortedList are included as an attachment. Test Run Requirements: Only submit one run that shows a sample client that instantiates a list object, reads in test data from the listData test file and writes the test results to the a3testFirstnameLastname file (for FirstnameLastname your Firstname and Lastname). Grading Criteria: ItemType class is correctly defined and implemented. UnsortedType class is correctly defined and implemented. Program compiles and runs. Implementation supports the operations given in the ADT functional requirements. A test driver is included to satisfy the test run demonstration. A copy of your test run output display is included in an output file named a3testFirstnameLastname Be sure to include 6 separate files: ItemType.h ItemType.cpp unsorted.h unsorted.cpp listDr.cpp Solution //---------------------------ItemType.cpp---------------------------------------------------------------------- ------- #include #include #include "ch03-ItemType.h" using namespace std; ItemType::ItemType() { value = 0; } RelationType ItemType::ComparedTo(ItemType otherItem) const { if (value < otherItem.value) return LESS; else if (value > otherItem.value) return GREATER;
  • 4. else return EQUAL; } void ItemType::Initialize(int number) { value = number; } void ItemType::Print() const { cout << value; } //---------------------------ItemType.h------------------------------------------------------------------------- ---- #include using namespace std; #ifndef ITEMTYPE_H #define ITEMTYPE_H const int MAX_ITEMS = 25; enum RelationType {LESS, GREATER, EQUAL}; class ItemType { private: int value; public: ItemType(); RelationType ComparedTo(ItemType) const; void Print() const; void Initialize(int number); }; #endif //---------------------------Unsorted.h-------------------------------------------------------------------------- --- #include "ch03-ItemType.h" using namespace std; #ifndef UNSORTEDTYPE_H #define UNSORTEDTYPE_H
  • 5. class UnsortedType { private: struct NodeType { ItemType info; NodeType* next; }; NodeType* listData; int length; NodeType* currentPos; public: UnsortedType(); ~UnsortedType(); void MakeEmpty(); bool IsFull() const; int GetLength() const; ItemType GetItem(ItemType& item, bool& found); void PutItem(ItemType item); void DeleteItem(ItemType item); void ResetList(); ItemType GetNextItem(); void SplitList(ItemType item, UnsortedType &list1, UnsortedType &list2); }; #endif //---------------------------Unsorted.cpp----------------------------------------------------------------------- ------ #include "hw2-UnsortedType.h" #include using namespace std; UnsortedType::UnsortedType() { length = 0; listData = NULL; }
  • 6. UnsortedType::~UnsortedType() { NodeType* tempPtr; while(listData != NULL) { tempPtr = listData; listData = listData->next; delete tempPtr; } } void UnsortedType::MakeEmpty() { NodeType* tempPtr; while(listData != NULL) { tempPtr = listData; listData = listData->next; delete tempPtr; } length = 0; } bool UnsortedType::IsFull() const { NodeType* location; try { location = new NodeType; delete location; return false; } catch(bad_alloc) { return true; } }
  • 7. int UnsortedType::GetLength() const { return length; } void UnsortedType::PutItem(ItemType item) { NodeType* location = new NodeType; location->info = item; location->next = listData; listData = location; length++; } ItemType UnsortedType::GetItem(ItemType& item, bool& found) { bool moreToSearch; NodeType* location; location = listData; found = false; moreToSearch = (location != NULL); while (moreToSearch && !found) { switch (item.ComparedTo(location->info)) { case LESS : case GREATER : location = location->next; moreToSearch = (location != NULL); break; case EQUAL : found = true; item = location->info; break; } } return item; } void UnsortedType::DeleteItem(ItemType item) {
  • 8. NodeType* location; NodeType* tempLocation; location = listData; if (item.ComparedTo(location->info) == EQUAL) { tempLocation = location; listData = listData->next; } else { while (!((item.ComparedTo((location->next)->info) == EQUAL))) location = location->next; tempLocation = location->next; location->next = (location->next)->next; } delete tempLocation; length--; } void UnsortedType::ResetList() { currentPos = NULL; } ItemType UnsortedType::GetNextItem() { if (currentPos == NULL) currentPos = listData; else currentPos = currentPos->next; return currentPos->info; } void UnsortedType::SplitList(ItemType item, UnsortedType &list1, UnsortedType &list2) { ItemType location; ResetList(); for (int counter = 1, length = GetLength(); counter <= length; counter++) {
  • 9. location = GetNextItem(); cout << "Parsing Item: "; location.Print(); cout << endl; switch (location.ComparedTo(item)) { case LESS : case EQUAL : list1.PutItem(location); break; case GREATER : list2.PutItem(location); break; }; }; } //------------------------------------------------listDr.cpp------------------------------------------------------ --- #include #include #include #include "ListDr-UnsortedType.h" using namespace std; void PrintList(UnsortedType&); void SplitList(UnsortedType&, ItemType); int main() { ifstream inFile; string command; int number; ItemType item; UnsortedType list; bool found; int numCommands; inFile.open("listhw.txt");
  • 10. if (!inFile) { cout << "Unable to open input file - ending program." << endl; exit(1); } inFile >> command; numCommands = 0; while (command != "Quit") { numCommands++; cout << "Command " << numCommands << ": " << command << " "; if (command == "PutItem") { inFile >> number; item.Initialize(number); list.PutItem(item); item.Print(); cout << " added to list" << endl; } else if (command == "GetItem") { inFile >> number; item.Initialize(number); item = list.GetItem(item, found); item.Print(); if (found) cout << " found in list." << endl; else cout << " not in list." << endl; } else if (command == "DeleteItem") { inFile >> number; item.Initialize(number); list.DeleteItem(item); item.Print();
  • 11. cout << " deleted from list" << endl; } else if (command == "GetLength") { cout << "Length of list = " << list.GetLength() << endl; } else if (command == "IsFull") { if (list.IsFull()) cout << "List is full." << endl; else cout << "List is not full." << endl; } else if (command == "MakeEmpty") { list.MakeEmpty(); cout << "List is empty." << endl; } else if (command == "PrintList") { cout << " List values" << endl; PrintList(list); } else if (command == "SplitList") { inFile >> number; item.Initialize(number); SplitList(list,item); } else cout << command << " is not a valid command." << endl; inFile >> command; }; cout << "Testing completed." << endl; inFile.close(); return 0; }
  • 12. //---------------------------------------- // PrintList // Non-member function to print all items in list // Pre: list has been initialized // Post: Each component in list has been written to cout //---------------------------------------- void PrintList(UnsortedType &list) { int length; ItemType item; list.ResetList(); length = list.GetLength(); for (int counter = 1; counter <= length; counter++) { item = list.GetNextItem(); item.Print(); cout << endl; } cout << "Length of list = " << length << endl << endl; } void SplitList(UnsortedType &list, ItemType item) { UnsortedType list1, list2; list.SplitList(item,list1,list2); cout << "The list has been split into two." << endl << endl; cout << "List 1:" << endl; PrintList(list1); cout << "List 2:" << endl; PrintList(list2); }