How do you handle duplicate elements in randomized quicksort?
Randomized quicksort is a popular sorting algorithm that relies on randomly choosing a pivot element and partitioning the input array around it. It has an expected running time of O(n log n) and a worst-case space complexity of O(log n). However, it can perform poorly when there are many duplicate elements in the input, as they can create unbalanced partitions and increase the recursion depth. Here are some ways to handle duplicate elements in randomized quicksort to improve its efficiency and stability.