Re: hacker challenge - traverse a list



Julienne Walker wrote:
...
I notice you didn't mention that the structure of the tree can't
change, so why not rotate away the left branches as you traverse?
> ...

Hew explicitly stated that this approach will "debatably" use O(log n) (or even O(n)) memory, which is a violation of the O(1) requirement.

--
Best regards,
Andrey Tarasevich
.



Relevant Pages

  • Re: hacker challenge - traverse a list
    ... Julienne Walker wrote: ... I notice you didn't mention that the structure of the tree can't ... so why not rotate away the left branches as you traverse? ... memory, which is a violation of the Orequirement. ...
    (comp.programming)
  • Re: Walk DOM Tree in Reverse?
    ... algorithm will traverse all nodes (sadly not necessarily visiting each ... the right child of the current root (plus at the beginning of the ... var fakeParent =!elem.parentNode; ... tree may be passed in. ...
    (comp.lang.javascript)
  • Re: hacker challenge - traverse a list
    ... Here is a little challenge - print the contents of a binary tree ... I assume there are no up links, otherwise the algorithm is trivial. ... space hence unbounded number of bits in a pointer? ... Left branch *not* leaf, rotate: ...
    (comp.programming)
  • Re: Depth First Search traversal of this list
    ... I am trying to traverse the list C)) in a way that the ... works by iterating over the items at one level in the tree. ... are deferred into a queue, which is processed after the atoms are visited. ... After collecting both the queue and current level items, we do the recursion to ...
    (comp.lang.lisp)
  • Re: Walk DOM Tree in Reverse?
    ... I think of .lastChild as a rightmost child ... algorithm will traverse all nodes (sadly not necessarily visiting each ... node is the root of a tree containing all the nodes. ...
    (comp.lang.javascript)