Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Modify the quick sort implementation in the textbook to sort the array using pivot as the median of the first, last, and middle elements of
Modify the quick sort implementation in the textbook to sort the array using pivot as the median of the first, last, and middle elements of the array. Add the modified quick sort implementation to the arrayListType class provided arrayListTypeh Ask the user to enter a list of positive integers ending with sort the integers, and display the pivots for each iteration and the sorted array.
Here is the provided arrayListType.h file. Please also explain where the codes should be as wellwhether its in the h or the cpp and explain why:
the last bit of code from the last pagealso the same bit cut off at the end of page is here:
template
void arrayListType::removeconst elemType& removeItem
int loc;
if length
cerr "Cannot delete from an empty list." endl;
else
loc seqSearchremoveItem;
if loc the item to be removed
removeAtloc; exists in the list
else
cout "The item to be deleted is not in the list."
endl;
end remove
template
arrayListType::arrayListTypeint size
if size
cerr "The array size must be positive. Creating
an array of size endl;
maxSize ;
else
maxSize size;
length ;
list new elemTypemaxSize;
assertlist NULL;
template
arrayListType::~arrayListType
delete list;
template
arrayListType::arrayListType
const arrayListType& otherList
maxSize otherList.maxSize;
length otherList.length;
list new elemTypemaxSize; create the array
assertlist NULL; terminate if unable to allocate
memory space
for int j ; j length; jcopy otherList
listj otherList.listj;
end copy constructor
template
const arrayListType& arrayListType::operator
const arrayListType& otherList
if this &otherListavoid selfassignment
delete list;
maxSize otherList.maxSize;
length otherList.length;
list new elemTypemaxSize; create the array
assertlist NULL; if unable to allocate memory
space terminate the program
for int i ; i length; i
listi otherList.listi;
return this;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started