Michael Chaney wrote:

>>>I don't think you understand postfix notation.  The order of operations
>>>is determined solely by their order in the list.  There is no need to
>>>worry about associative, distributive, etc.  Those only apply to infix
>>>notation.  Also, operator precedence is an artifact of infix notation,
>>>it is irrelevant in postfix (and prefix).
>>>
>>hi mike,
>>
>>    yes thats correct by their order in the list. but isnt that already a
>>fix expresssion? i mean given a postfix expresssion , it is already a fix
>>expression where the proper association is in place.. but when you convert
>>it to infix expression and you analyze it, it will come up huge possible of
>>combinations of parenthesis as what have you said. 
>>
>
>Why would I convert it to infix?  There's no need to.  If I did,
>however, part of that conversion would be to add the proper parentheses.
>I don't have the time or patience to prove it, but to generate all
>possible combinations in postfix notation, then convert each one to
>infix notation, would probably be the easiest way to come up with all
>possible and relevant sets of parentheses for the infix problem.  But
>there's simply no need to.
>
>>yes postfix will
>>simplify things but it will miss you something along the way. on the safe
>>side, its better to see all possible things... sacha gave its answer and
>>jessie prove that it is still be express.
>>
>
>Postfix shows you all possible ways.  Please, before you continue
>arguing with everybody here, learn about postfix.  It is blatantly
>obvious that you don't understand it.
>
>Michael
>
I agree fully with you mike, dido also pointed it out that he believes 
i'm right that
fooler doesn't fooly understand postfix =)

here is an example:
infix: 41 = 9 + 32 = ( 8 * 4 ) + 9 = ( ( 9 - ( 9 / 9 ) ) * ( ( ( ( 9 + 9 
) + 9 ) + 9 ) / 9 ) + 9--> ( from me )
postfix: 41 = 9 9 + 9 + 9 + 9 / 9 9 9 / - * 9 + --> (from sacha )

and here is some java code: --> (from me)

String exp = "9 9 + 9 + 9 + 9 / 9 9 9 / - * 9 +";

public double process(String exp){
        StringTokenizer st = new StringTokenizer(exp," ");       
        Stack stack = new Stack();
        while(st.hasMoreTokens()){           
            String s = st.nextToken();
            boolean numeric=true;
            Double item=null;
            try{
                item = new Double(s);
            }catch(NumberFormatException ex){
                numeric=false;
            }
            if(numeric)
                stack.push(item);
            else{
                Double op1 = (Double)stack.pop();
                Double op2 = (Double)stack.pop();               
                Double result=null;
                if("+".equals(s))
                    result=new Double(op1.doubleValue()+op2.doubleValue());
                if("-".equals(s))
                    result=new Double(op2.doubleValue()-op1.doubleValue());
                if("*".equals(s))
                    result=new Double(op1.doubleValue()*op2.doubleValue());
                if("/".equals(s))
                    result=new Double(op2.doubleValue()/op1.doubleValue());
                stack.push(result);
            }
        }
        return(((Double)stack.pop()).doubleValue());
    }

this is just a quick hack, pardon me if it's not quite as clean as it 
probably could be.

hmm ... maybe someone can write a
1) a servlet that would divide the range into equal sized chunks
2) an applet that will download a chunk and compute the results
3) a servlet that would receive the results and determine the answer!!!

Sacha, you read hitch hikers guide??? It would have been great if 42 was 
really
the answer to this question.

-- 
jezbum

============================================================
Jessie Evangelista<[EMAIL PROTECTED]>
Developer, SMetrix Inc. ,Philippines
Tel no.: +6328438064
============================================================

  Three Rings for the Elven-kings under the sky,
    Seven for the Dwarf-lords in their halls of stone,
  Nine for mortal men doomed to die,
    One for the Dark Lord on his dark throne.
  In the land of Mordor where the Shadows lie

  One Ring to rule them all,
    One Ring to find them,
  One Ring to bring them all,
    and in the darkness bind them.
  In the Land of Mordor where the Shadows lie 
    -- J.R.R. Tolkien



_
Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph
To leave: send "unsubscribe" in the body to [EMAIL PROTECTED]

To subscribe to the Linux Newbies' List: send "subscribe" in the body to 
[EMAIL PROTECTED]

Reply via email to