You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ft = FTree([1,2,3,4,5])
ft.select(15) # this throws IndexError: list index out of range in line 36
Expected behavior:
According to CP4 book, the select function "finds the smallest index/key i so that the cumulative frequency in the range [1..i]>=k". So the function should return 6 because the smallest index (of FTree.ft array) where the cumulative frequency is at least 15 is 6
The text was updated successfully, but these errors were encountered:
Hello.
Looks like there is a bug in the select function
cpbook-code/ch2/ourown/fenwicktree_ds.py
Line 36 in fa53432
Steps to reproduce:
Expected behavior:
According to CP4 book, the select function "finds the smallest index/key i so that the cumulative frequency in the range [1..i]>=k". So the function should return 6 because the smallest index (of FTree.ft array) where the cumulative frequency is at least 15 is 6
The text was updated successfully, but these errors were encountered: