> I have a bst which contain words(Strings), what I'm trying to is do an
> inorder traversal so as I can print the words in alphabetical order. The
[quoted text clipped - 14 lines]
> return words;
> }
You create a new LinkedQueue in each and every node, and in the end only
return the Queue created for the root node.
What you probably wanted is this:
public LinkedQueue flatten(BstNode x){ // x = root node
LinkedQueue words = new LinkedQueue();
flatten(x, words);
return words
}
private void flatten(BstNode x, LinkedQueue words){
if(x != null){
// traverse the left subtree
flatten(x.getLeft(), words);
words.qAdd(x.getData());
System.out.println(x.getData());
// traverse the right subtree
flatten(x.getRight());
}
}

Signature
In pioneer days they used oxen for heavy pulling, and when one ox
couldn't budge a log, they didn't try to grow a larger ox. We shouldn't
be trying for bigger computers, but for more systems of computers.
--- Rear Admiral Grace Murray Hopper
Chris Hatton - 13 Feb 2005 13:59 GMT
>>I have a bst which contain words(Strings), what I'm trying to is do an
>>inorder traversal so as I can print the words in alphabetical order. The
[quoted text clipped - 36 lines]
> }
> }
I can't belive I did that! <d:-)
Well, you live and learn.
Cheers,
Chris