the following code is recursive method i'm writing...
it walks through a binary tree that has stored a prefix expression such as (+ 2 (+2 3)) and is supposed to return it a infix expression like this (2 + (2 + 3)).
public String buildInfix(ETree pointer)
String myInfix ="";
if(pointer.getTypeOf() == 1)
ETree left = ((Internal)pointer).getLeft();
String store = buildInfix(left);
myInfix += "( " + store + " ";
myInfix += ((Character)((Internal)pointer).getObject()).charValue() + " ";
ETree right =((Internal)pointer).getRight();
store = buildInfix(right);
myInfix += store + " )";
if(pointer.getTypeOf() == 2) //found a Constant
int temp =((Integer)((Constant)pointer).getObject()).intValue();
String number = "" + temp;
when i use a simple expression such as (+ 2 4) it work perfectly fine and returns (2 + 4)
but if i make it complicated like (+2 (* 2 3)) then the function gets caught in a infinite loop...
i noticed this when i put in some print statements...the function gets hung on the 2 and the +...the pointers don't seem to move on to the next value...
does anyone know why????
i'd really appreciate the help...
Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!
Working with files is a moderately common task in Java. For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.
However, when your application has vi…
This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop.
Define While Loop: