MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / random_pivot

Function random_pivot

divide_and_conquer/kth_order_statistic.py:17–23  ·  view source on GitHub ↗

Choose a random pivot for the list. We can use a more sophisticated algorithm here, such as the median-of-medians algorithm.

(lst)

Source from the content-addressed store, hash-verified

15
16
17def random_pivot(lst):
18 """
19 Choose a random pivot for the list.
20 We can use a more sophisticated algorithm here, such as the median-of-medians
21 algorithm.
22 """
23 return choice(lst)
24
25
26def kth_number(lst: list[int], k: int) -> int:

Callers 1

kth_numberFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected