c语言如何在二项式堆中求最大值

问题描述

我正在尝试用 c 语言实现二项式堆。 我检查了我遇到的所有示例,但它们都找到了最小值。

struct BinomialNode* Binomial_Heap_Minimum(struct BinomialHeaP* H){
    struct BinomialNode* x = (struct BinomialNode* )malloc(sizeof(struct BinomialNode));
    struct BinomialNode* y = (struct BinomialNode* )malloc(sizeof(struct BinomialNode));
    struct BinomialNode* z = (struct BinomialNode* )malloc(sizeof(struct BinomialNode));
    x = H->head;
    y = NULL;
    z = NULL;
    int min = 23656;
    while (x){
        if (x->key <= min){
            min = x->key;
            y = x;
        }
        z = x->sibling;
        x = z;
    }
    return y;
}```

I want to go through all the nodes and find the greatest value. With the code below,I can find the min one,but when I reverse the code,I can't find the biggest one.

I would be glad if you help.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)