Lab 10 Instructions This lab contains four (4) necessary files: 1. Lab 10.cpp 2.
ID: 3919287 • Letter: L
Question
Lab 10 Instructions
This lab contains four (4) necessary files:
1. Lab 10.cpp
2. Largest.h
3. Smallest.h
4. Hybrid.h
(I did also include rBubble.h, just for reference.)
Item 1: Needs some slight modifications for the addition of Item 4, Hybrid.h.
Items 2 and 3: (Smallest.h and Largest.h) Need to be written mostly by you, but you will find them to be a cinch, since I don't care in the least HOW you do it, and Google exists. I DO ask, however, that you use that block of code provided, AND that you write them in a recursive manner, hence the inclusion of the rBubble.h file -- just for reference.
Item 4: Lastly, and by far most importantly, once you've written the smallest and largest functions, I want you to (somehow -- and it is COMPLETELY up to you how) -- in some creative way, COMPOSE them, to create a your own sorting algorithm. Incorporate the concept of recursive function calls as much as possible. This is what you will turn in as Hybrid.h and is worth at least as much as the other three files combined.
If you do something that I find particularly impressive or clever, I will award extra credit pointsgenerously.
Largest.h code
Smallest.h Code
Hybrid.h Code
rBubble.h
Explanation / Answer
int largest(int x[], int num)
{
int temp, largest;
// Find a place for this particular block code:
for (int i = 0; i<num-1; i++) {
if (x[i] > x[i + 1])
{
temp = x[i + 1];
x[i + 1] = x[i];
x[i] = temp;
}
}
largest = x[num-1]
//////////////////////////////////////////////
return largest;
}
int smallest(int x[], int num)
{
int temp, smallest;
// Find a place for this particular block code:
for (int i = 0; i<num-1; i++) {
if (x[i] < x[i + 1])
{
temp = x[i + 1];
x[i + 1] = x[i];
x[i] = temp;
}
}
smallest = x[num-1]
//////////////////////////////////////////////
return smallest;
}
int hybrid(int x[], int num)
{
if (num == 1){
return;
}
else {
x[num-1] = largest(x,num);
hybrid(x,num-1);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.