Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*Unordered Array List Type Source Code:************* //.H File #Ifndef H_unorderedArrayListType #Define H_unorderedArrayListType #Include ArrayListType.H Class **********Unordered Array List Type Source Code:************* //.h file #ifndef H_unorderedArrayListType

*Unordered Array List Type Source Code:************* //.H File #Ifndef H_unorderedArrayListType #Define H_unorderedArrayListType #Include \"ArrayListType.H\" Class

**********Unordered Array List Type Source Code:*************

//.h file

#ifndef H_unorderedArrayListType

#define H_unorderedArrayListType

#include \"arrayListType.h\"

class unorderedArrayListType: public arrayListType

{

public:

void insertAt(int location, int insertItem);

void insertEnd(int insertItem);

void replaceAt(int location, int repItem);

int seqSearch(int searchItem) const;

void remove(int removeItem);

unorderedArrayListType(int size = 100);

//Constructor

};

#endif

//.cpp file

#include

#include \"unorderedArrayListType.h\"

using namespace std;

void unorderedArrayListType::insertAt(int location,

int insertItem)

{

if (location = maxSize)

cout

else if (length >= maxSize) //list is full

cout

else

{

for (int i = length; i > location; i--)

list[i] = list[i - 1]; //move the elements down

list[location] = insertItem; //insert the item at

//the specified position

length++; //increment the length

}

} //end insertAt

void unorderedArrayListType::insertEnd(int insertItem)

{

if (length >= maxSize) //the list is full

cout

else

{

list[length] = insertItem; //insert the item at the end

length++; //increment the length

}

} //end insertEnd

int unorderedArrayListType::seqSearch(int searchItem) const

{

int loc;

bool found = false;

loc = 0;

while (loc

if (list[loc] == searchItem)

found = true;

else

loc++;

if (found)

return loc;

else

return -1;

} //end seqSearch

void unorderedArrayListType::remove(int removeItem)

{

int loc;

if (length == 0)

cout

else

{

loc = seqSearch(removeItem);

if (loc != -1)

removeAt(loc);

else

cout

}

} //end remove

void unorderedArrayListType::replaceAt(int location, int repItem)

{

if (location = length)

cout

else

list[location] = repItem;

} //end replaceAt

unorderedArrayListType::unorderedArrayListType(int size)

: arrayListType(size)

{

} //end constructor

****Ordered Array list type source code*******

//.h file

#ifndef H_orderedArrayListType

#define H_orderedArrayListType

#include \"arrayListType.h\"

class orderedArrayListType: public arrayListType

{

public:

void insertAt(int location, int insertItem);

void insertEnd(int insertItem);

void replaceAt(int location, int repItem);

int seqSearch(int searchItem) const;

void insert(int insertItem);

void remove(int removeItem);

orderedArrayListType(int size = 100);

//Constructor

};

#endif

//.cpp file #include #include \"orderedArrayListType.h\"

using namespace std; void orderedArrayListType::insert(int insertItem) { if (length == 0) //list is empty list[length++] = insertItem; //insert insertItem //and increment length else if (length == maxSize) cout else { //Find the location in the list where to insert //insertItem. int loc;

bool found = false;

for (loc = 0; loc { if (list[loc] >= insertItem) { found = true; break; } }

for (int i = length; i > loc; i--) list[i] = list[i - 1]; //move the elements down

list[loc] = insertItem; //insert insertItem length++; //increment the length

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

List the functions of a database application.

Answered: 1 week ago

Question

=+Does your conclusion change if a 5 .01 is used?

Answered: 1 week ago