Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1- please send me the remaining part of this code which is the implementation of the Binomial heap(insertion and display of the minimum element) const

1- please send me the remaining part of this code which is the implementation of the Binomial heap(insertion and display of the minimum element)

const int MAXN = 100005;

struct node { int degree; int key; node *child, *sibling;

node(int k) { degree = 0; key = k; child = sibling = NULL; } };

node *head = NULL;

node *merge(node *h1, node *h2) { if (h1 == NULL) { return h2; } if (h2 == NULL) { return h1; } node *merged_heap = NULL; node *prev = NULL, *curr = NULL, *next = NULL; if (h1->degree <= h2->degree) { merged_heap = h1; h1 = h1->sibling; } else { merged_heap = h2; h2 = h2->sibling; } curr = merged_heap; while (h1 != NULL && h2 != NULL) { if (h1->degree <= h2->degree) { curr->sibling = h1; h1 = h1->sibling; } else { curr->sibling = h2; h2 = h2->sibling; } curr = curr->sibling; } if (h1 != NULL) { curr->sibling = h1; } else { curr->sibling = h2; } return merged_heap; }

node *merge_binomials(node *h1, node *h2) { node *h = merge(h1, h2); if (h == NULL) { return h; } node *prev = NULL, *curr = h, *next = h->sibling; while (next != NULL) { if (curr->degree != next->degree || (next->sibling != NULL && next->sibling->degree == curr->degree)) { prev = curr; curr = next; } else { if (curr->key <= next->key) { curr->sibling = next->sibling; next->sibling = curr->child; curr->child = next; curr->degree++; } else { if (prev == NULL) { h = next; } else { prev->sibling = next; } curr->sibling = next->child; next->child = curr; curr = next; } } next = curr->sibling; } return h; }

node *insert(int key) { node *newnode = new node(key); head = merge_binomials(head, newnode); return head; }

node *reverse(node *curr)

2- please provide me C++ program for the Huffman coding using bitwise operators. I already asked you many times but when you are sent the code was not completed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions