Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

foreach not applicable to type - binary tree sort

private static void iterateall(BinaryTree foo) {
    Stack<BinaryTree> nodes = new Stack<BinaryTree>();
    nodes.push(foo);
    while (!nodes.isEmpty()) {
        BinaryTree node = nodes.pop();
        if (node == null)
            continue;
        System.out.println(node.node);
        nodes.push(node.right);
        nodes.push(node.left);
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #foreach #applicable #type #binary #tree #sort
ADD COMMENT
Topic
Name
9+5 =