corrected bug in heapify and added both max_heapify and min_heapify version