top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Implementation of Heap using Arrays in C?

+1 vote
761 views

Can someone help me with the code and algo?

posted Nov 19, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Heap is nothing but a part of RAM.
It is used only when you are trying to allocate a memory dynamically.
So, Through "malloc" and "calloc" system call you can allocate a memory dynamically.
So, When ever you allocating memory through 'malloc" and "calloc" memory has been given from Heap.

Example;
if you want an integer array of 10 elements.
then you will need 40bytes. (size of element (4) * total no of element (10))

#include<stdio.h>
main()
{
  int *p;
  p = (int*)malloc(40);  // p = (int*)calloc(10,4);
}
answer Dec 9, 2014 by Chirag Gangdev
I think question is on heap data structure. Check if you want to modify your response.

http://en.wikipedia.org/wiki/Heap_(data_structure)
http://en.wikipedia.org/wiki/Binary_heap
Ooopss.. Sorry For Misunderstanding...
Do you like to correct the implementation so that it helps the bigger mass.
No.. Sir.. I have no idea about it...
No issue let me give a try when I am free.
Similar Questions
–1 vote

Say you are given two arrays where second array is duplicate with one missing element. What should be the best possible way to find that missing element -
array1: [1,2,3,4,5,6,7]
array2: [1,3,4,5,6,7]

Missing Element: 2

...