aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/algorithms/impl
diff options
context:
space:
mode:
Diffstat (limited to 'algorithms/impl')
-rw-r--r--algorithms/impl/median.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/algorithms/impl/median.py b/algorithms/impl/median.py
index 7bcce76..ba51c71 100644
--- a/algorithms/impl/median.py
+++ b/algorithms/impl/median.py
@@ -2,6 +2,8 @@
# This file is licensed under the terms of the MIT License.
# See LICENSE.txt for details.
+from algorithms.impl.quicksort import quicksort_random
+
from heapq import *
def calc_median_heaps(xs):
@@ -31,7 +33,7 @@ def calc_median_heaps(xs):
def calc_median_sort_first(xs):
if not xs:
return 0.0
- xs.sort()
+ quicksort_random(xs)
if len(xs) % 2:
return xs[len(xs) // 2]
else: