I have this C++ coding problem I need help with. Question: An Unsorted Type ADT
ID: 3682666 • Letter: I
Question
I have this C++ coding problem I need help with.
Question: An Unsorted Type ADT is to be extended by the addition of function SplitLists, which has the following specifications:
Function: Divides list into two lists according to the key item.
Preconditions: list has been initialized and is not empty.
Postconditions: list1 contains all the items of list whose keys are less than or equal to item's key; list2 contains all the iteams 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 ADT.
I just need a code example what this funcation would look like and how one might implemented it array based and linked member based.
Explanation / Answer
Computer program design can be made much easier by organizing information into abstract data structures (ADS) or abstract data types (ADTs). For example, one can model a table of numbers that has three columns and an indeterminate number of rows, in terms of an array with two dimensions:
(1) a large number of rows, and
(2) three columns.
The purpose of an abstract data structure (ADS) is to narrow the semantic gap between the user's programming constructs or application software and the computing hardware (otherwise known as the bare machine).
a)
b) #include "ItemType.h"
class UnsortedType
{
public:
UnsortedType();
void MakeEmpty();
bool IsFull() const;
int LengthIs() const;
void RetrieveItem(ItemType& item, bool& found);
void InsertItem(ItemType item);
void DeleteItem(ItemType item);
void ResetList();
void GetNextItem(ItemType& item);
private:
int length;
ItemType info[MAX_ITEMS];
int currentPos;
} ;