I can't seem to understand how this works despite reading this - median of three values strategy
I understand that in quick sort, I can pick an arbitrary value to be my pivot and start from there. For a median of three quick sort, some online article said to pick the first, last and the middle values in the unsorted array and then pick the value that is the center of these 3 values (e.g 56, 12, 45 -45 will be picked). The example also shows it with 9 values, making it easy to pick the first, last and middle values.
What if the unsorted array is of 8 values only like 34, 66, 57, 45, 20, 98, 92, 41
? Is my median value going to be 45
given that the first, last and middle values are 34, 45, 41
respectively?
Thanks.