Purchase Solution

C++ code to implement SplitLists

Not what you're looking for?

Ask Custom Question

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

Purchase this Solution

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.

Solution Preview

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

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

...

Purchase this Solution


Free BrainMass Quizzes
Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Javscript Basics

Quiz on basics of javascript programming language.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

C# variables and classes

This quiz contains questions about C# classes and variables.

Basic Networking Questions

This quiz consists of some basic networking questions.