C++ Recursive Array Problem

Completed Posted Aug 6, 2003 Paid on delivery
Completed Paid on delivery

Write a recursive array-based implementation of the retrieval operation for the ADT list given in the attached file (and copied below). The operation should take the array, an item and the size of the array as parameters and return the position of the item. Be sure that the function calls itself with a smaller problem size. //Header File const int MAX_LIST = 10; typedef int listItemType; class listClass { public: listClass(); //list operations: bool ListIsEmpty() const; int ListLength() const; void ListInsert(int NewPosition, listItemType NewItem, bool& Success); void ListDelete(int Position, bool& Success); void ListRetrieve(int Position, listItemType& DataItem, bool& Success) const; private: listItemType Items[MAX_LIST]; int Size; int Index(int Position) const; }; //CPP File #include "ListA.h" listClass::listClass() : Size(0) { } bool listClass::ListIsEmpty() const { return bool(Size == 0); } int listClass::ListLength() const { return Size; } void listClass::ListInsert(int NewPosition, listItemType NewItem, bool& Success) { Success = bool( (NewPosition >= 1) && (NewPosition <= Size+1) && (Size < MAX_LIST)); if (Success) { for (int Position = Size; Position >= NewPosition; --Position) { Items[Index(Position+1)] = Items[Index(Position)]; } Items[Index(NewPosition)] = NewItem; ++Size; } } void listClass::ListDelete(int Position, bool& Success) { Success = bool((Position >= 1) && (Position <= Size)); if (Success) { for (int FromPosition = Position+1; FromPosition <= Size; ++FromPosition) { Items[Index(FromPosition-1)] = Items[Index(FromPosition)]; } --Size; } } void listClass::ListRetrieve(int Position, listItemType& DataItem, bool& Success) const { Success = bool((Position >= 1) && (Position <= Size)); if (Success) { DataItem = Items[Index(Position)]; } } int listClass::Index(int Position) const { return Position-1; }

## Deliverables

1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. 2) Complete ownership and distribution copyrights to all work purchased.

## Platform

Windows

C Programming Engineering MySQL PHP Software Architecture Software Testing

Project ID: #2961027

About the project

4 proposals Remote project Active Aug 7, 2003

Awarded to:

vw821235vw

See private message.

$5 USD in 5 days
(94 Reviews)
4.3

4 freelancers are bidding on average $8 for this job

idleswell

See private message.

$12.75 USD in 5 days
(175 Reviews)
5.9
lonapz

See private message.

$10.2 USD in 5 days
(10 Reviews)
2.8
chupendra

See private message.

$5.1 USD in 5 days
(0 Reviews)
0.0