Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Heaps

Hi all

I have a problem in creating a 3 ary heap using linked list strcutrue ( not array)
It is a normal problem of bulding,deleting,insrting,etc.. but with a 3 ary linked list structure

any hints on how to start with or any site to help will be highly appreciated

thanks alot
:cool: :WAVE:
[327 byte] By [Eng.b] at [2007-11-11 9:56:58]
# 1 Re: Heaps
Hey Engineer,
Have you solved the problem set you have, I am given the same problem set in my university and facing difficulties!!...Would you please tell me how did you implement the program?!

Thanks,
happyMan at 2007-11-11 20:59:41 >
# 2 Re: Heaps
hey happyMan

yes am semi-finished with my project...just need to analyze it
by the way you may be in my class ;)

first of all think of the problem of a linked list one
so to have a linked ist we need some pointers to the node
we need a pointer to point to a previous node and one to link to the next one
in this problem also i used an index to know the position of each element ( like in arrays)

now for example to extract the maximum value ...it will be the root of the tree ( heap )for sure since all the other elemnts will be less than or equal to it ( keep this in mind)

in inserting:
take in consederation all the cases like inserting at the begining and ed of list

the trick in the problem is to use index

for example if you have a node h
then to index the parent you could say
(h->index/3) -1 ( for the equations we have studied)

while the h->index greator than h above equation we set h to previous node

and we continue the code ( and dont forget to call the heapfy )

the problem i cant describe the program ( it is too long)

if u have any problem in any part i will be pleased to answer you

Good luck in the problem set

:WAVE:
Eng.b at 2007-11-11 21:00:41 >