Fix index off by 1

This commit is contained in:
Danila Fedorin 2019-09-27 14:35:28 -07:00
parent 5c43ffb602
commit 022533dc4a
1 changed files with 2 additions and 2 deletions

View File

@ -7,9 +7,9 @@ def qselect(i, xs):
left = [x for x in xs if x < pivot]
right = [x for x in xs if x >= pivot]
if i > len(left):
if i > len(left) + 1:
return qselect(i - len(left) - 1, right)
elif i == len(left):
elif i == len(left) + 1:
return pivot
else:
return qselect(i, left)