Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You need to define the following data types. ELEMENT is a data type that contains a field named key, which is of type int. Note

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

You need to define the following data types. ELEMENT is a data type that contains a field named key, which is of type int. Note that ELEMENT should not be of type int. HEAP is a data type that contains three fields named capacity (of type int), size (of type int), and H (an array of type ELEMENT with index ranging from 0 to capacity). The functions that you are required to implement are Initialize(n) which returns an object of type HEAP with capacity n and size 0. This function requires you to perform dynamic memory allocation, given the demand. BuildHeap(heap, A), where heap is a HEAP object and A is an array of type ELEMENT. This function copies the elements in A into heap->H (starting from H1] and uses the linear time build heap algorithm to obtain a min-heap of s ize from the given array A. Insert(heap, k, flag) which inserts an element with key equal to k into the min-heap heap. When flag-0, the function does not do any additional printing. When flag-1, the function prints out the heap content before the insertion, and the heap content after the insertion. . DeleteMin(heap, flag) which deletes the element with minimum key and returns it to the caller When flag-0, the function does not do any additional printing. When flag-1, the function prints out the heap content before the deletion, and the heap content after the deletion. You need to define the following data types. ELEMENT is a data type that contains a field named key, which is of type int. Note that ELEMENT should not be of type int. HEAP is a data type that contains three fields named capacity (of type int), size (of type int), and H (an array of type ELEMENT with index ranging from 0 to capacity). The functions that you are required to implement are Initialize(n) which returns an object of type HEAP with capacity n and size 0. This function requires you to perform dynamic memory allocation, given the demand. BuildHeap(heap, A), where heap is a HEAP object and A is an array of type ELEMENT. This function copies the elements in A into heap->H (starting from H1] and uses the linear time build heap algorithm to obtain a min-heap of s ize from the given array A. Insert(heap, k, flag) which inserts an element with key equal to k into the min-heap heap. When flag-0, the function does not do any additional printing. When flag-1, the function prints out the heap content before the insertion, and the heap content after the insertion. . DeleteMin(heap, flag) which deletes the element with minimum key and returns it to the caller When flag-0, the function does not do any additional printing. When flag-1, the function prints out the heap content before the deletion, and the heap content after the deletion

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

Students also viewed these Databases questions

Question

Explain the factors affecting dividend policy in detail.

Answered: 1 week ago

Question

Explain walter's model of dividend policy.

Answered: 1 week ago

Question

3. What should a contract of employment contain?

Answered: 1 week ago

Question

1. What does the term employment relationship mean?

Answered: 1 week ago