Question
I need help with a QuickSort medianOf3 hoarePartition C++ program. This is what I have so far: #ifndef QUICKSORT_H #define QUICKSORT_H #include using std::swap; //note
I need help with a QuickSort medianOf3 hoarePartition C++ program. This is what I have so far:
#ifndef QUICKSORT_H #define QUICKSORT_H
#include
using std::swap;
//note returns INDEX of median template
//when a is a pointer, *a is the dereference operator (gives value a points to) T* m; if(*a < *b){ if(*b < *c) m=b; else if(*c < *a) m=a; else m=c; } else{ //b <=a if(*a < *c) m=a; else if(*c < *b) m=b; else m=c; } return m-A; //m-A is the number of elements from A[0]
//remember: l and r are INLCUSIVE (just like Lomuto) template
if (i < j) swap(A[i],A[j]); else return 0; }
template
}
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