green flag to reset and update length turbo mode is recommended for long lists, shift press green flag
efficient sorting algorithm https://scratch.mit.edu/projects/1299696214/ unstable not adaptive space - O(1) inplace time compl - O(nlog2 n) arrange it so that its a max heap (every parent of a tree node is bigger than it). the children of a node are node*2+1 and node*2+2 once its a max heap, we know that the first item must be the largest so we put it at the end, then heapify everything that isnt before the end, keep doing this and decreasing "the end" until "the end" is the first item eg: [4, 7, 2, 6, 9, 1, 8, 5] the tree is 4 [0] |---7 [0*2+1 = 1] |___|---6 [1*2+1 = 3] |___|___|---5 [3*2+1 = 7] |___| |___|---9 [1*2+2 = 4] | |---2 [0*2+2 = 2] ___|---1 [2*2+1 = 5] ___|---8 [2*2+2 = 6] then loop through each parent and if one of its children is greater than it, swap them and do the same to that childs tree do this multiple times from floor(len(arr)/2)-1 and go up from there indexing from 0 this should be the result [9, 7, 8, 6, 4, 1, 2, 5] 9 [0] |---7 [1] |___|---6 [3] |___|___|---5 [7] |___| |___|---4 [4] | |---8 [2] ____|---1 [5] ____|---2 [6] now, put that at the end and keep heapifying it while decreasing "the end" "the end" is just the first item