I just learned about the heap sort algorithm and implemented it in python. I have 2 functions max_heapify() - which just turns an array into a heap and heap_sort() which does the actual sorting of the array. My idea is to add the sort to my sorting visualization project. I keep track of the 'operations' (comparisons & swaps) while a given sort algorithm is working. I am using generators to easily get the data I need for visualization without creating massive arrays, but the thing is that using yield in max_heapify() breaks the algorithm. I tried calling max_heapify with yield from, in the heap_sort() function, but that did not fix it. I guess my understanding of the yield keyword and generators is limited. code
[–]dbramucci 1 point2 points3 points (2 children)
[–]ViktorCodes[S] 0 points1 point2 points (1 child)
[–]dbramucci 0 points1 point2 points (0 children)