Write a function quickSort that takes an unsorted list of integers as input and returns a sorted list using the quick sort algorithm. Your implementation should be recursive and should use the first element of the input list as the pivot element.
Your function should also include the following modifications to the basic quick sort algorithm:
-
For input sizes below a certain threshold (e.g., 10 elements), switch to an insertion sort algorithm instead of recursively calling quick sort. This is because insertion sort is generally faster for small input sizes.
-
To improve performance, use a random pivot element instead of always using the first element of the input list.
Your implementation should have an average time complexity of and should use in-place sorting (i.e., without creating a new copy of the input list).
Note: you can assume that the input list contains only integers.