C
C
Chemodan2282020-02-17 23:48:12
C++ / C#
Chemodan228, 2020-02-17 23:48:12

The function doesn't work. What to do?

void swap(int *a,int *b){
    int temp=*a;
    *a=*b;
    *b=temp;
}
int parent(int i){
   return (i-1)/2;
}
void shitf_up(binary_tree *s,int pos){
   int Parent=parent(pos);
   if (pos>0 && (s->val[pos] > s->val[Parent])){
       swap(&s->val[pos],&s->val[Parent]);
       shitf_up(&s,Parent);
   }
   return;
}

Guys, the shift_up function does not work. Can you give me some idea why it doesn't work. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mercury13, 2020-02-18
@TopToster

So far I can see ...
shitf_up(s,Parent);
Maybe you also messed up with the order of the heap, but this is not visible on such a piece of code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question