Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSC 240 Exercise 2 Extend the UnsortedType class with the following function and signature: SplitLists(UnsortedType list, ItemType item, UnsortedType& list1, UnsortedType& list2) The SplitLists function

CSC 240

Exercise 2

Extend the UnsortedType class with the following function and signature:

SplitLists(UnsortedType list, ItemType item, UnsortedType& list1, UnsortedType& list2)

The SplitLists function will behave according to the following specifications:

Definition: divides list into two lists according to the value of item.

Preconditions: list has been initialized and is not empty. list1 and list2 are empty.

Postconditions: list1 contains all the items of list whose values are less than or equal to the value of item. list2 contains all of the items of list whose values are greater than the value of item.

Complete the following implementations of the SplitLists function:

1) Implement SplitLists as an array-based member function of UnsortedType.

2) Implement SplitLists as a linked member function of UnsortedType.

Test each of the implementations in a driver using the following set of integers:

{ 5, -12, 34, 34, 5, 45, 8, -6, 15, 40, 20, 2, 1, 12 }

Use the following version of the ItemType class provided by the author:

class ItemType

{

public:

ItemType();

RelationType ComparedTo(ItemType) const;

void Print(std::ostream&) const;

void Initialize(int number);

private:

int value;

};

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

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions