Member Avatar

I'm implementing a generi method that's supposed to traverse a binary tree in PostOrder but when I attempt to use it, the Iterator doesn't work as It should when I attempt to use ot on a Binary Tree, can anyone spot my mistake in the code? Thanks. The method makes use of a generic POIterator class which implements a generic Iterator<T> here's th POIterator class public class POIterator<T> implements Iterator<T>{ Deque<BNode<E>>someStack = new LinkedList<BNNode<E>>(); BNode<E> position; public T next(){ position = position.pop(); if(!position.hasLeftNode()) return position.getInfo(); else{ position = position.getLeftNode(); somestack.push(position);} next();//recurisive call position = position.pop(); if(!position.hasRightNode()) next();//recursive call }//end of …

Member Avatar
0
26
Member Avatar

hi, i'm currently learning C on my own. i explicitly made a binary tree just to see if my postorder procedure works. i have no idea why but at the end of running the program, before it does the last procedure, this appears: [IMG]http://i56.tinypic.com/2nb52xx.jpg[/IMG] everything else works fine. i know it must be the [B]postorder[/B] which has the problem but i have no idea why. please help me. below is my code: [CODE]#include <stdio.h> #include<stdlib.h> #include<conio.h> struct node { struct node *LeftNode; char data; struct node *RightNode; }; node *makeNode(char c); void visit(struct node *N); void postorder (struct node *N); …

Member Avatar
0
7

The End.