943,754 Members | Top Members by Rank

Ad:
Sep 27th, 2007
0

How to implement heap in lisp?

Expand Post »
I am trying to implement heap in CLisp. I have already done it by makin a linear data strcuture with no left / right pointers. But now I want to use a nested list format which contains (el () ()) at the highst level.
The problem I am facing with is how to define a recursive case for insertion. Heap requires the tree to be complete.

I approach the issue as follows:

1. I will take a heap and an element
2. I will add the element in the last node keeping it a complete tree
3. I wil swap the child with parent if it is greater than the parent

But I am stuck at the second step i.e. how to add an element without making the tree incomplete? KIndly help me on this!!!!!!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
lsprog is offline Offline
1 posts
since Sep 2007
Oct 23rd, 2007
-1

Re: How to implement heap in lisp?

LISP????

Yuch!!!

Hoppy

P.S. I hate Lisp!
Reputation Points: 53
Solved Threads: 13
Junior Poster
hopalongcassidy is offline Offline
148 posts
since Oct 2007
Dec 10th, 2007
0

Re: How to implement heap in lisp?

Way to beef up your post count, hopalongcassidy. If you hate Lisp so much, then avoid any thread with "Lisp" or "Scheme" in the title.

Sheesh.

I'm sorry for that lsprog.
I haven't done much mucking about with stack and heap programming in Common Lisp. When you mention "CLisp" do you mean GNU Clisp - the REPL? Or are you referring to Common Lisp?

As far as my programming experience has taught me, mucking about with stacks and heaps is reserved for the language handler (interpreter/VM/whatever-else-you-want-to-call-it). Would you be able to show me a bit of code, and I will more than try my hardest to help you.
Reputation Points: 23
Solved Threads: 2
Junior Poster in Training
indienick is offline Offline
71 posts
since Aug 2005
Dec 10th, 2007
0

Re: How to implement heap in lisp?

Click to Expand / Collapse  Quote originally posted by indienick ...
Way to beef up your post count, hopalongcassidy. If you hate Lisp so much, then avoid any thread with "Lisp" or "Scheme" in the title.

Boy,. I didn't know I would strike such a nerve. I guess I would be sensitive too if I was constantly trying to keep an arcane language from going extinct.

Hoppy
Reputation Points: 53
Solved Threads: 13
Junior Poster
hopalongcassidy is offline Offline
148 posts
since Oct 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Legacy and Other Languages Forum Timeline: question in matlab
Next Thread in Legacy and Other Languages Forum Timeline: Stupid Scheme and Let statements





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC