Re: hacker challenge - traverse a list
- From: cri@xxxxxxxx (Richard Harter)
- Date: Fri, 29 Feb 2008 20:34:25 GMT
On Fri, 29 Feb 2008 11:29:29 -0800, Andrey Tarasevich
<andreytarasevich@xxxxxxxxxxx> wrote:
Richard Harter wrote:
Here is a little challenge - print the contents of a binary tree
in order only using O(1) additional memory.
What exactly is a "binary tree" in this case?
A tree with left and right child links only, no parent link;
traverse in the order specified by left and right.
In a tree that has child->parent links in addition to parent->child
links the solution is trivial. No hacks necessary.
True.
In a tree that only has parent->child links the the problem has no
solution with O(1) memory (the way you "defined" it in your "debatably"
part).
Not so. It depends upon what further restrictions you place.
Richard Harter, cri@xxxxxxxx
http://home.tiac.net/~cri, http://www.varinoma.com
Save the Earth now!!
It's the only planet with chocolate.
.
- References:
- hacker challenge - traverse a list
- From: Richard Harter
- Re: hacker challenge - traverse a list
- From: Andrey Tarasevich
- hacker challenge - traverse a list
- Prev by Date: Re: hacker challenge - traverse a list
- Next by Date: Re: hacker challenge - traverse a list
- Previous by thread: Re: hacker challenge - traverse a list
- Next by thread: Re: hacker challenge - traverse a list
- Index(es):
Relevant Pages
|