Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
6ed7c20c
Kaydet (Commit)
6ed7c20c
authored
Nis 10, 2014
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Update comment for the comparison table to use measured results rather than predicted.
üst
bed54b56
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
heapq.py
Lib/heapq.py
+10
-9
No files found.
Lib/heapq.py
Dosyayı görüntüle @
6ed7c20c
...
@@ -202,16 +202,17 @@ def _heapify_max(x):
...
@@ -202,16 +202,17 @@ def _heapify_max(x):
# Number of comparisons for n random inputs, keeping the k smallest values:
# Number of comparisons for n random inputs, keeping the k smallest values:
# -----------------------------------------------------------
# -----------------------------------------------------------
# Step Comparisons Action
# Step Comparisons Action
# 1
2*k
heapify the first k-inputs
# 1
1.66*k
heapify the first k-inputs
# 2 n
-k
compare new input elements to top of heap
# 2 n
- k
compare new input elements to top of heap
# 3 k*lg2(k)*(ln(n)-l
g
(k)) add new extreme values to the heap
# 3 k*lg2(k)*(ln(n)-l
n
(k)) add new extreme values to the heap
# 4 k*lg2(k) final sort of the k most extreme values
# 4 k*lg2(k) final sort of the k most extreme values
#
#
# n-random inputs k-extreme values number of comparisons % more than min()
# number of comparisons
# --------------- ---------------- ------------------- -----------------
# n-random inputs k-extreme values average of 5 trials % more than min()
# 10,000 100 13,634 36.3%
# --------------- ---------------- ------------------- -----------------
# 100,000 100 105,163 5.2%
# 10,000 100 14,046 40.5%
# 1,000,000 100 1,006,694 0.7%
# 100,000 100 105,749 5.7%
# 1,000,000 100 1,007,751 0.8%
#
#
# Computing the number of comparisons for step 3:
# Computing the number of comparisons for step 3:
# -----------------------------------------------
# -----------------------------------------------
...
@@ -234,7 +235,7 @@ def _heapify_max(x):
...
@@ -234,7 +235,7 @@ def _heapify_max(x):
# comparisons = k * log(k, 2) * (log(n,e) - log(k, e))
# comparisons = k * log(k, 2) * (log(n,e) - log(k, e))
#
#
# Worst-case for step 3:
# Worst-case for step 3:
# ---------------------
# ---------------------
-
# In the worst case, the input data is reversed sorted so that every new element
# In the worst case, the input data is reversed sorted so that every new element
# must be inserted in the heap:
# must be inserted in the heap:
# comparisons = log(k, 2) * (n - k)
# comparisons = log(k, 2) * (n - k)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment