Explore BrainMass
Share

C++ code to implement SplitLists

This content was STOLEN from BrainMass.com - View the original, and get the solution, here!

I need help with this question so that I can use it to study for my midterm.

An Unsorted Type ADT is to be extended by the addition of function
SplitLists, which has the following specifications:

SplitLists(UnsortedType list, ItemType item, UnsortedType& list1, UnsortedType& list2)
Function: Divides list into two lists according to the key of item.
Preconditions: list has been initialized and is notempty.
Postconditions: list1 contains all the items of list whose keys are less than or equal to item's key; list2 contains all the items of list whose keys are greater than item's key.

a. Implement SplitLists as an array-based member function of the Unsorted
List ADT.
b. Implement SplitLists as a linked member function of the Unsorted List

© BrainMass Inc. brainmass.com September 19, 2018, 7:24 pm ad1c9bdddf - https://brainmass.com/computer-science/cpp/c-code-to-implement-splitlists-576359

Solution Preview

(a)
void UnsortedType::SplitLists(ItemType item, UnsortedType&
list1, UnsortedType& list2)
{
int counter = 0;

list1.MakeEmpty();
list2.MakeEmpty();

...

Solution Summary

The solution gives detailed C++ code to implement SplitLists as both an array-based and linked member function of the Unsorted List ADT.

$2.19