0

Hi james, can you please correct me .

Thank you in avdvance.

0

Sorry, I won't do your homework for youb I will help you do it if you're prepared to put in some brainpower.

If you want to store Strings like "20" in your BST then the data field needs to be a String not a char, then that code you have extracting chars from the String isn't needed...

Edited by JamesCherrill

0

How will you handle on this?

bsto.Insert(new String("5*20"));
bsto.postOrder(bsto.root);

how do i extract those elements in the strings if i will not convert it char ?
0

You need to parse that into "5" "*" "20"
for that you will need to look at one char at at time, but the numbers need to be put back together.

0

Is this what you mean

    bsto.Insert("5");
    bsto.Insert("*");
    bsto.Insert("20");
0

Hi james, but i want the user's to input the infix.I don't want to make it static

0

I don't know how to do with the operators...if i will input like this 2*5/9

-1

@Hiroshe,

[QUOTE]

Step 1: Parse infix into BST recursively.
Step 2: Write BST in postfix notation.

[/QUOTE]

If i will input infix 5*3/9,in your step 1 what should i do to the operators?..if 5 is the root what will i do to the next element which is * where should i will insert this in right or left of the root?

Edited by toring

-1

@james,
It's not hard to test each char to see if it's a numeric or an operator,yes we can use the Character.isDigit,but what i my question what should i do if i meet operators where do i insert this.

-1

I have no idea if i encounter operator what should i do?how do i insert this to the tree?

Thank you in advance.

-1

@Hiroshe,what if there is -,+,or lets say 5-9*6/3+2

Thank you in advance

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.