如何解决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 举报,一经查实,本站将立刻删除。