max_heapify procedure on heap

后端 未结 5 642
無奈伤痛
無奈伤痛 2021-01-22 02:27

i have these procedure

#include 
using namespace std;

int parent(int i ){
    return  i/2;
}

int left(int i ){
    return  2*i;
}

int right(i         


        
5条回答
  •  深忆病人
    2021-01-22 03:13

    Perhaps you shouldn't always call max_Heapify tail-recursively, but instead return when you've hit the bottom size of the sorting heap... What happens is that your program runs out of stack.

    Also, check out std::swap.

提交回复
热议问题