From 77fb90170b539459ee16ba71c7c4caa825675966 Mon Sep 17 00:00:00 2001 From: "Jack.ht.lee" Date: Fri, 19 Aug 2016 23:26:50 +0800 Subject: [PATCH] fix bug --- heapSort.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heapSort.py b/heapSort.py index 38d6df4..b324d59 100644 --- a/heapSort.py +++ b/heapSort.py @@ -8,7 +8,7 @@ def heapSort(alist): for j in range(tempLen//2-1, -1, -1): preIndex = j preVal, heap = alist[preIndex], False - while 2 * preIndex <= tempLen - 1 and not heap: + while 2 * preIndex < tempLen - 1 and not heap: curIndex = 2 * preIndex + 1 if curIndex < tempLen - 1: if alist[curIndex] < alist[curIndex+1]: