tree walking -- saved recursion state
From: Mikito Harakiri (mikharakiri_at_iahu.com)
Date: 01/05/04
- Previous message: Michel Rueher: "CPAIOR'04 : LAST CALL FOR PAPERS"
- Next in thread: Bart Demoen: "Re: tree walking -- saved recursion state"
- Reply: Bart Demoen: "Re: tree walking -- saved recursion state"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 5 Jan 2004 09:38:25 -0800
I have a tree:
class Node {
private Vector children = new Vector();
private Node parent = null;
}
I want to write a method nextLeaf(). It's very easy to write a Node's method
that makes recursive depth-first enumeration:
public void walkSubTree() {
for( int i = 0; i < children.size(); i++ )
walkSubTree(children.elementAt(i));
}
Now, I wonder how can I reconciliate recursive nature of "server" function
walkSubTree() with a "client" function nextLeaf() need to receive nodes
supplied by walkSubTree() in a "discontinous" manner. If after finding a
leaf could I save the recursion state somehow...
- Previous message: Michel Rueher: "CPAIOR'04 : LAST CALL FOR PAPERS"
- Next in thread: Bart Demoen: "Re: tree walking -- saved recursion state"
- Reply: Bart Demoen: "Re: tree walking -- saved recursion state"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]