the goal is to determine whether [pivot selection as average of extrema] is comparable to median-of-three
which probably is to say How does pivot selection as presented here compare to MoT?
If that is goal of this post rather than goal of the code presented, CR is the wrong forum for that.
(These preliminary remarks done with, I'll more or less follow the source top to bottom.)
Personal dislikes:
- code where I don't know at first glance
a) what the idea was creating it
b) what I can ethically do with it.
- waste of screen space (viz. circumventing SE's bulleted list here)
I
I suggest leaving license information out of doc comments, using blank lines to separate things not (visually) separated otherwise, only, and using markup sparingly and with as little intrusion as feasible (e.g., </p> at end of last line of paragraph).
class QSortSAVP(what does the 2ndSstand for?) consider separating recursion handling, pivot selection (done), partitioning, and "driver" (main()looks the type - I'd prefer a separate/nested class).
Implement aninterface Sorter<T>.As such, first step is…is this comment up to date? (Where wouldarithmetic overflowbecome a problem? SeedeterminePivot()'s doc comment, too. You should be able to get rid of the (current) special case forfirstIteration.)[] sort([], boolean createCopy)looks excessive for a non-production strength implementation. I'd prefer mentioning the case for a copy insort([] arr)'s doc comment (especially if that returned its argument) or[] sortCopy([]).
Why open code [Arrays.copyOf([]arr, int newLength)](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Arrays.html#copyOf(T%5B%5D, int))?
sort([] arr, pivotVal, int lowIndex, int highIndex, …)
- Intrusive tracing impedes readability. If need be, use an appropriate package.
- I don't quite get the// all entries in given range are less than or equal to pivot(which they conceivably are) - thereturn;is in order becausedeterminePivot()never rounds up (which I don't find documented anywhere) and all entries are equal
- not passing (in some convenient way) information about pivot selection between invocations of this method andint determinePivot([] arr, int lowIndex, int highIndex)throws away information: the overall low fromlowIndextohighIndexwill stay the low fromlowIndextotempLowIndex, analogously for high.
- If at all, just handle (MAX_)RECURSION_DEPTHwhere you handleRECURSION_COUNT
- determine the pivot at top of this method instead of before each recursive callvoid handlePrint(object)&…Line()see suggestion about logging/tracing package