I am attempting to downheap on an array from the last interior node all the way up to the root, so that I am making mini-heaps from the bottom up. I have an algorithm that I believe will do this though I far from 100% certain at this point.
I cannot figure out how index errors in my code are happening. My immediate concern here is for this downheap algorithm to work, but I'm not able to get any meaningful output, and any help would be greatly appreciated.
As reference, I don't get index errors when I use index of i in the recursive call. As soon as I replace i with bkIndex , I get those IndexErrors. If I use i, in the recursive call, I get an output of
Array:
3 6 12 7 2 1 5 8 4 10 11 0 13 9 14
Heap:
13 13 12 13 10 11 13 8 4 10 11 0 13 9 14
Which is still wrong, but at least I wasn't getting an index error.
And now I'm questioning if I'm even close to getting this algorithm down. If it's really that far off, I might just scrap the whole thing and start over... Does it look ok? If it does, and I am close, how would I make it ok?
What I have tried:
http://www.pasteall.org/64356/python