hacker challenge - traverse a list
- From: cri@xxxxxxxx (Richard Harter)
- Date: Fri, 29 Feb 2008 17:56:24 GMT
Here is a little challenge - print the contents of a binary tree
in order only using O(1) additional memory. In other words you
can't use recursion or simulate it with a stack. As far as I
know you can't do this without some kind of hack. Also AFAIK
there is no way to do this that should ever be used in real code.
Rules? We don't need no steenking rules! Use whatever language
you like, though I suppose this is a natural for C based
languages. Tag bit solutions (i.e. mark a link as visited when
we go down it and unmark it when we come back up) don't count
because (a) everyone thinks of it, and (b) it (debatably) uses
O(log n) memory. Platform dependencies are okay - this a hack,
after all.
Richard Harter, cri@xxxxxxxx
http://home.tiac.net/~cri, http://www.varinoma.com
Save the Earth now!!
It's the only planet with chocolate.
.
- Follow-Ups:
- Re: hacker challenge - traverse a list
- From: Nelu
- Re: hacker challenge - traverse a list
- From: Andrey Tarasevich
- Re: hacker challenge - traverse a list
- From: Julienne Walker
- Re: hacker challenge - traverse a list
- From: Ben Pfaff
- Re: hacker challenge - traverse a list
- Prev by Date: Re: Compiler Loop Unswitching
- Next by Date: Re: hacker challenge - traverse a list
- Previous by thread: data specs
- Next by thread: Re: hacker challenge - traverse a list
- Index(es):
Relevant Pages
|