Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you please let me know if I have written the makeHeap function correctly? struct Entry { int key; char* value; }; typedef struct Entry

Can you please let me know if I have written the makeHeap function correctly?

image text in transcribed

struct Entry { int key; char* value; };

typedef struct Entry Entry;

struct Heap { int capacity; int size; Entry** elements; };

typedef struct Heap Heap;

Heap* makeHeap(int capacity) { //Make the heap Heap* theHeap = calloc(1, sizeof(Heap)); //set its capacity to param theHeap->capacity = capacity; //inital size is 0 theHeap->size = 0; //elements contains pointers (references) to Entry objects. Entry **elements[capacity]; //iterate capacity times allocating an entry reference for each element to be placed int i = 0; for(; i

theHeap->elements = *elements;

return theHeap; }

makeHeap: Should return a pointer to a newly allocated Heap with the given capacity, a size of 0, and an elements array allocated with the given capacity. The elements array should contain pointers (references) to Entry objects

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

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions

Question

3. What are the current trends in computer hardware platforms?

Answered: 1 week ago