Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

[C Homework Help] - Heap implementation.

c homework heap data structures memory allocation arrays

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1 Nailer91

Nailer91

    CC Newcomer

  • Member
  • PipPip
  • 11 posts

Posted 04 December 2014 - 06:21 AM

Hi,

As part of an assignment for my OS class I need to implement a heap which stores the smallest value at the root with arrays.

I suppose it would need the following methods, insert() , pop(), resize() at a minimum. Could anyone give me some advice on the subject. The heap will store an array of data which I have already defined in another struct by the way.

 

Any help would be appreciated,

Thanks.



#2 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts

Posted 04 December 2014 - 11:56 PM

Are you familiar with how heaps work? Not just what they do, but how they work internally?


Edited by dargueta, 04 December 2014 - 11:56 PM.

sudo rm -rf / && echo $'Sanitize your inputs!'


#3 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts

Posted 05 December 2014 - 06:54 AM

Here's a video tutorial about heap works.

 

Do you have any code already?



#4 gonerogue

gonerogue

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 197 posts

Posted 05 December 2014 - 09:44 AM

^ @OP is referring to the heap data structure:

http://en.wikipedia....data_structure)

 

Here is a C implementation of a binary heap:

https://github.com/f...c/binary-heap.h

https://github.com/f...c/binary-heap.c






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download