How to implement heap as a binary tree in lisp?
- From: riahasan85@xxxxxxxxx
- Date: Thu, 27 Sep 2007 11:34:24 -0700
I am trying to implement heap in CLisp. I have already done it in 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!!!!!!!
.
- Follow-Ups:
- Re: How to implement heap as a binary tree in lisp?
- From: andrew.baine@xxxxxxxxx
- Re: How to implement heap as a binary tree in lisp?
- Prev by Date: Re: Learning lisp
- Next by Date: Re: declare 64 bit integers?
- Previous by thread: declare 64 bit integers?
- Next by thread: Re: How to implement heap as a binary tree in lisp?
- Index(es):
Relevant Pages
|