Postfix in expression tree

Hello,
I am trying to put this postfix stack :
Stack postfix = [2, 3, +]
into an expression tree.
This is the code i have written to make a tree:
     private void makeTree(Stack postfix)     {          System.out.println("Creating tree in makeTree() " + postfix);          Stack tempStack = new Stack();                    if (!postfix.isEmpty())          {               String s = (String) postfix.pop();               System.out.println("Character popped from postfix stack " + s);                              if (isOperator(s) == false)               {                    //store popped number on tempStack                    tempStack.push(s);                    System.out.println("Pushed into tempStack " + tempStack);               }               else //popped element is an operator               {                    //create the tree with the nodes                    System.out.println("Popped element is an operator: " + s);                    System.out.println(tempStack);                    if(!tempStack.isEmpty())                    {                         System.out.println("Stack is not empty!");                         Node right = (Node) tempStack.pop();                         Node left = (Node) tempStack.pop();                         tempStack.push(new Node (s, left, right));                    }                                   }               root = (Node) tempStack.pop();          }     }//end of method makeTree()
When i check the tempStack with a print statement, it says that the stack is empty, thats why it doesn't access this part of the code:
if(!tempStack.isEmpty())                    {                         System.out.println("Stack is not empty!");                         Node right = (Node) tempStack.pop();                         Node left = (Node) tempStack.pop();                         tempStack.push(new Node (s, left, right));                    }
I have put so many print statements in this code and other methods, i just can't find out what doesn't work.
I would appreciate any help.
thanks, jen

I don't know... i just can't get this to work. This is what i have done with the code now:
import java.util.*;
public class ExpressionTree
     static String node;
     private class Node
          public String data;
          public Node left;
          public Node right;
          public Node (String data)
               this.data = data;
          public Node (String data, Node left, Node right)
               this(data);
               this.left = left;
               this.right = right;
     }//end of class Node
     private Node root;
     public ExpressionTree(Stack postfix)
        System.out.println("Constructor Expression Tree created");
          buildTree(postfix);
    public String buildTree(Stack s)
           String e = (String) s.pop();
           if (isOperator(e) == true)        
            String right = buildTree(s);
                  String left = buildTree(s);
            Node(e, left, right);
            node = e + left + right;
                  return node;
        else // operand assumed
             Node(e);
             node = e;
             return node;
}the error message i get is:
java:42: cannot resolve symbol
[javac] symbol : method Node (java.lang.String,java.lang.String,java.lang.String)
[javac] location: class ExpressionTree
[javac]           Node(e, left, right);
[javac] ^
I don't know whats wrong with this, because i am passing 3 strings to the Node method.
Thanks for your help!.

Similar Messages

  • Using expression trees to evaluate an expression

    i have a three parameters like age, sex and location. Now, my users while registration, can specify an expression like, age > 25 and age < 30 and sex = male OR location = 'London'. Now i get an incoming request which has certain values for age, sex and location (say: age=26 sex = male location = 'London'). Then i want to get a list of all the users registered with me who satisfies the incoming criteria. Do you think an expression tree would help me in this case? can pls someone guide me?

    actually i have a fixed list of operators and operands. The only variation being that users while registration might use only a subset of those operators and operands e.g. some users may just give an expression such as 'sex=male' and some other users could give an expression such as 'sex = female AND age > 21'. So when i get an incoming request saying sex = female and age = 22 then only my second kind of users would be selected and suppose if i get an incoming message like sex = male , age = 33 then my first kind of users (though no age is specified by that user while registration but still he would be selected as the expression said sex = male and that is one of the parameters of the incoming request) would be selected. Now how do i create such a solution using an expression tree, which would evaluate the incoming request and then match it with the expression specified by the various users to find the list of those users who qualify according to the incoming request parameters. any ideas??

  • Expression Trees and Recurive Building

    Hi. I am working on a project to build a Expression tree, given input in infix notation
    ie. ( 4 * 3 ) * 5 - ( 2 * 15 )
    I have coded up everything, however there seems to be a small error somewhere (possibly in halting the recursion).
    Could someone please have a look @ the code. It would be really appreciated..
    see: http://www.pastebin.com/106673
    Thnaks. Dyclops

    I have four observations for you:
    1. You go to all the bother to tokenize the expression and then you turn around and reassemble the tokens and lose all the tokenizing information! You might as well just parse the original string.
    2. Nowhere in your parsing do you call your getNext() method, so your current position never changes; thus, you never finish parsing the expression (this is, I think, your poblem).
    3. Your getNext method does not handle spaces or tabs.
    4. Your low-level number parser only handles one-digit numbers Numbers like 891 or 2004 will totally confuse your parser.
    Other than that, your parsing tree logic looks perfectly OK.

  • Recursive Algorithm for Postfix/Infix expressions

    For those that are unaware if infix is an expression like (5 + (3 * 2)) or (3 + 5) * 10, then the respective postfix expressions are 5 3 2 * + and 3 5 + 10 *.
    Basically I need to do two things if given a postfix expression: 1) determine if it's a valid postfix expression, and 2) if so, evaluate it.
    Now, I can (and did) do this with stacks easily. Very easy to understand with stacks. However, I need to do both using recursion, not stacks.
    I've tried to work out some kind of algorithm but what i'm doing just isn't working. Can someone help with the necessary algorithm needed for both methods? tia

    overrule wrote:
    TuringPest wrote:
    overrule wrote:
    This is an option many regulars here should consider. If you don't know, don't answer. Simple as that.i was attempting to be helpful. just because i misread doesnt mean i dont deserve to post here.
    way to be an internet thug though.No it's okay to be stupid. You can even be elected moderator if you can prove it.I thought you liked TuringPest? Well like might be a strong word...

  • Allignment problem in application express tree region

    hi,
         i have an issue regarding the tree regions allignment in a page. i tried to create a simple tree region with the basic code given below..
    select case when connect_by_isleaf = 1 then 0
           when level = 1             then 1
           else                           -1
           end as status,
           level,
           'xxx'   as title,
           null as icon,
           "RECORD1" as value,
           null as tooltip,
           null as link
    from "#OWNER#"."TABLE_TREE"
    where ex_id = :EX_ID
    start with "RECORD2" is null and ex_id = :EX_ID
    connect by prior "RECORD1" = "RECORD2" and ex_id = :EX_ID
    for the above code used in the tree region type i got the following tree structure.
    the above trees structure display the child records from same parent are not coming in same allignment. the child record with no further child is coming with a space before the record and a child record with further childs to it is getting displayed from the starting of the line.
    please help me out.

    i am unable to attache screen shots. please find the screen shots here
    link: http://postimg.org/image/uasvm7nlt/

  • Looking for code creating binary tree from expression(prefix)!

    I wanna use expression to generate binary expression tree. For example:
    I have expression in string: 1+2*3;
    then generate a tree like:
    +
    1 *
    2 3
    does some body have example code?

    sniff sniff I thought we were having lasagna? Smells like homework!

  • Parsing an Algebraic Expression

    Hi ,
    Can any body provide me an idea to parse an algebraic expression in Java.Are there any built in classes for parsing an expression and evaluating after substituting the values for variables in the expression?
    If no classes are availble,plz provide me any algorithm for doing that.
    Thanks in Advance

    Observe:
    Parsing an expression is essentially the act of converting the expression from infix notation to postfix notation. Infix requires parens and precedence to specify order of operations but post fix unambiguously specifies them by the order of the tokens
    So something like
    "a+b*c" becomes "a b c * +"
    "a*b+c" becomes "a b * c +"
    "(a+b)*c" becomes "a b + c *"
    notice that arguments (variables and numbers, the leaves of the implied expression tree) occur in the same sequence in both the infix and the postfix notation. Thus you can view the parsing as a filtering process that passes arguments directly from input to output and all the filter is doing is re-arranging the order of the operators.
    All this rearranging of operators can be done with a single stack and it is all based on this observation:
    When you saw a string like "a op1 b op2 c" you run across the token for the first operator before you have even collected its right argument. You must put that operator somewhere and a OpStack is the place to put it. You don't know whether to emit op1 until you have had a look at the next operator, op2. If op2 was higher priority than op1, then op2 gets to consume the argument b first. In that case op2 just gets added to the stack on top of op1.
    However if op2 was less than or equal in precedence to op1, well then op1 can now be flowed to the output stream and allowed to act on the b argument that is already out on the output stream.
    This means that the fundamental operation of the expression parser is the business of pushing an opertor token onto the stack, but first spewing to the output all the other operators on the stack that had a higher or equal priority. If we give this function a name like opStack.pushSpew(token) it could look something like this:
    class OpStack{
      Stack s = new Stack();
      void pushSpew(List out, Token t){
        Token tos;
        while(!s.empty() && (tos = peek()).priority >= t.priority){out.add(pop());}
        push(t);
    }Next thing to observe is that a grouper, like open and close parens, behaves in the following way. An open paren acts like a very high priority operator when pushed to the stack in that it spews nothing. The previous op is NOT allowed to eat the argument that is about to come right after the open paren. However once the open paren marks the stack, the open should be a lower priority than any real op that gets pushed onto the stack above it because it must delay going out until every real op in the group had its shot. The close paren should also act like a very low priority op. It should spew every op upto but not including the open paren that started this group.
    As a computation trick, if you set the priority of an open lowest of all, and the priority of a close just above that, and you just push the open onto the stack instead of pushSpewing it onto the stack, you will get the desired behavior. You with then pushSpew the close paren and it will dump everything from the stack to the output up to but not including the open. At this point it is easy to check the balance. If you do not have an open/close pair sitting as the top two elements on the stack then the parens (or the brackets or the braces) were not properly nested.
    We are almost done. There are post fix operators like factorial and prefix operators like minus that we need to deal with. It only makes sense to evaluate these suckers from the inside out i.e. if you had a string of prefixs on an arg
    op1 op2 op3 arg
    the only sensible order is defined by parens like this
    (op1 (op2 (op3 arg) ) )
    and in post fix that would be
    arg op3 op2 op1
    that is exactly what you would get if you just pushed each prefix op onto the stack in the order you saw them and then popped them off after you dumped out the argument.
    Post ops should also work from the inside out
    arg op1 op2
    being
    ( (arg op1) op2 )
    and you get this behavior by just dumping a post op to the output when you see it.
    There is only one special concern. What should you do if you saw, both pre ops and post ops on the same arg?
    is "op1 arg op2" done like this: "(op1 arg) op2" or "op1 (arg op2)"? Well, why should these be any different from regular diadic ops, let precdence decide. An espression like minus three factorial "-3!" should be interpreted as take the factorial of 3 and then negate it (and not the other way around!) so let the priority of factorial be greater than that of minus and just do the standard pushSpew with post ops to let them spew out any high priority pre ops before they go onto the stack, but then unlike binary ops, the post op immediately comes off the stack and goes to the output because post ops bind up right away.
    Now if you are not careful with your precedences you could get "wierd" behavior. If for example you did not assign a high priority to a factorial, you could write expressions like "3+4!" and the priority would treat that like "(3+4)!" the plus would bind tighter than the factorial. It is hard for me to imagine a language where you would want the effects of either a postfix or a prefix operator to span across multiple arguments combined by single diadic operator, but that is really up to you. You certainly could have a language where you gave a very low precedence to ~ which could mean the boolean NOT, a lower precedence than the diadic operator >= which would allow you to write "~ a >= b" which would mean "~(a>=b)"
    After all it is your language, do what you want. None the less I would advise against alowing ANY pre or post op to have a priority LESS than that of ANY diadic operator.
    Lots of talk here but to recap, the code is quite simple:
    while((t = getNextToken()) != null){
      switch (t.type()){
        case ARG:  out.add(t); break; // arguments pass straight to output
        case PRE:  stack.push(t); break; // pre ops are just pushed (binding them to the next arg)
        case OPEN: stack.push(t); break; // Opens just push, they don't spew to output
        case DI: stack.pushSpew(out,t); break; // Diadic ops do the standard pushSpew
        case POST: stack.pushSpew(out,t); out.add(stack.pop()); break; //spew and then go out
        case CLOSE: stack.pushSpew(out,t); stack.removeOCpair(); // spew all ops in group
          // and then check if you had a balancing open
    }That just about does the entire parse. If you can find the tokens in the input you can rearrange them into the output. You do need to flush the opStack when you are done with the input stream and there is a convenient trick to doing that. The trick is this. Invent an invisible Open and Close pair, invisible meaning that they never show up in any input stream, you just made them up and pretended that that expression started with an invisible OpenExp and at the end it closed with a CloseExp.
    The CloseExp at the end will act like any grouper, it will flush the stack looking for the corresponding opener. IF there was any unbalanced grouper, like say an extra unbalanced open paren somewhere in the expression, the CloseExp will spew its way down to that unbalanced paren and then fail when it discovers that it does not match the open in the call to remove the OC pair. The is a way to do error detection. Use a fictional group on the entire expression to both flush the remainder of the opStack and to do a final check for unbalanced groupers.
    In fact, while we are on the topic of error checking there is another one that is very good to include. Basically in a real expression if you ignore the parens, the progression should be an alternation between args and diadic ops, with an occasional pre or post op thrown in.
    A simple count tells you where you are. Go up to 1 when you pass an argument, go back down to zero when you see a diadic operator. You should start at zero, because there have been no arguments or ops yet. In state zero the only legal things to do are to put in a pre op or an arg. Once you have an arg out there the only legal things to do are to have a post op or a diadic op. This little state machine will tell you if and when you have got either a pair of arguments together with no op between them, or a pair of ops with no argument between them. You should start at state = 0 and you should end at state = 1 (unless you allow empty expressions) So we can beef up the error checking with a very simple addition. The guts of the parse will now look like this:
    state = 0
    stack.push(Token.OpenExp); // start off with an open of the expression
    while((t = getNextToken()) != null){
      switch (t.type()){
        case ARG:  assertStateIs(0); out.add(t); state = 1; break;
        case PRE:  assertStateIs(0); stack.push(t); break;
        case OPEN: stack.push(t); break;
        case DI: assertStateIs(1); stack.pushSpew(out,t); state =0; break;
        case POST: assertStateIs(1);stack.pushSpew(out,t); out.add(stack.pop()); break;
        case CLOSE: stack.pushSpew(out,t); stack.removeOCpair();
    stack.pushSpew(out,Token.CloseExp); stack.removeOCpair();
    assertState(1);
    return out;So - there it is, in outline form the way that you parse an expression.You build 3 classes, Token, ExpressionParser, and OpStack
    Token is just a bucket that holds a name, a type (ARG, PRE, OPEN, DI, ...) and a precedence.
    OpStack is just a wrapper for a reqular stack that will hold Tokens and allow for a pushSpew function.
    ExpressionParser is little other than a Map full of all your Tokens. This map allows the parser to map substrings, tokens, that it finds in the input like >= to actual Tokens with a capital T. It will have two main methods:
    1) the parse method which I have almost completly written for you. It takes an input string and will fill up an output list placing the Tokens in post fix order, which is your parse tree.
    2) the routine getNextToken which will walk the input string, skipping white space when appropriate, looking for names, numbers, and operators and building each chunk that it finds into a Token.
    One last complexity note. If you want to allow functional notation like sqrt(3) you are using parens in a fundamentally different way than was described above (ditto when you use brackets to represent array indexing like x[5]) the fundamentally different thing that you are doing is that you are allowing an argument (a name) like "sqrt" to sit right next to another argument like "3" with no binary op in between. You are using an "implied" binary op at that point. You have saved the user from typing "sqrt FUNCTIONCALL (3)" or "x ARRAYINDEX 5"
    I will leave it as an exercise to the reader to see how you make a small modification to the OPEN case to detect and deal with an implied operation. Don't forget that you must tell the state error checker what you are doing.
    And now that I have shown you how fundamentally simple it is to build an expression parser let me comment on why you do not find a standard library routine for doing this.
    The primary reason is that there is no such thing as a "standard" math expression. Parsing is based on a language and there is no one language. Are you going to allow hex numbers in your expressions? How about scientific notation? Is = equality or assignment? Do you allow functional notation? Array indexing? Multi-dimensional array (like x[2,3])? How about string constants like "foobar"? How do you embed quotes in your quoted strings? Are you allowing comments, block comments, statements, code, Lisp expressions, complex numbers, implicit type conversion, type casting? At what point does it stop being a simple expression and start being a full computer language?
    Furthermore, most of the work you will quickly see if you use what I have suggested to build an expression parser, it how to give your user feedback that the expression that he typed had problems and where. There is no stardard UI for error feedback in things that don't parse correctly. Are you just going to dump cryptic strings to the console or are you going to highlight something in a text box somewhere?
    All the work turns out to be that of defining your language and determining your set of tokens and what precedence you will employ. Once you get that all worked out, parsing the expressions only takes the ten or fifteen lines of code that I outlined.
    And look, it only took several thousands of words to explain why it only takes about 15 lines of code to parse expressions once you have decided upon your language and written your tokenizer.
    Enjoy

  • Modify the logical operator in an Expression

    Hi,
    How to alter an Operator ("LIKE" to "EQUAL") inside an Expression already built - before execution ?
    Let me explain my problem :
    I have a central Toplink Adapter class which is responsible for executing all Expressions passed from different modules.
    Each module is passing an Expression object to this Adapter.
    There is a DeletionStatus column in almost all the tables whose value could be "Y" or "N".
    Almost all Expressions append (through AND) this DeletionStatus column checking the value to "Y" or "N".
    The problem here is the subordinates while building the Expression have used LIKE operator many places on this DeletionStatus column rather than EQUAL (or EQUALS).
    My objective now is to regulate within the adapter class that EQUAL/s to be used to improve performance.
    Sitting in the Adapter class...after accepting the Expression object as a parameter...how can i alter the Expression(/query) such that if the DeletionStatus column is part of the Expression built...then modify the Operator to be EQUAL/s only and not LIKE.
    Seamlessly.....irrespective of the Operator used by the subordinates....the Adapter always executes with EQUALS operator thereby improving on the performance of SQL execution.
    Please help.
    Thank you very much in advance.
    Regards,

    I would think you would be best off change the code that is using like() and change it to equal() instead of leaving this code incorrect, and trying to mung it elsewhere.
    If you really want to mung it, you could walk the Expression tree and look for LIKE and the field and switch the operator of the RelationExpression.
    James : http://www.eclipselink.org

  • Parsing XPath Expressions

    Is there a Java API that parses XPath expressions and produces the resultant XPath tree in memory?
    For example the xpath expression: /a/b[c/d]/e/f
    will produce a tree with "a" as the root node, "b" as a sub-node, "c" and "e" as subnodes of "b" and so on.
    I don't want one that is to be evaluate against and XML document. I just want the XPath Expression tree to be build in memory.
    Thanks

    hi,
    look at javacc, a compiler very popular, with many examples.
    Raymond

  • Is it possible to use the Copy Express to copy across Approval Procedures?

    Hi,
    We're running SBO 8.8 for a new customer and need to copy the Approval Procedures from one database to another - there are absolutely loads and it'll too painful to create them manually.
    We can't see the option in the Copy Express tree - can anyone help?
    Is it possible to use the Copy Express to copy the Approval Procedures object? Is there another way (perhaps via insert statement in SQL)?
    Please assist!
    Thanks,
    Mohsen

    Hi Mohsen,
    Due to the complicity of the approval procedures, I think it is too hard to build a copy tool for this under current system structure.
    As for insert statement in SQL, it is absolutely a no go. Unless you want the risk to lose SAP support, never try that. You have to re-create them.
    Thanks,
    Gordon

  • Binary tree  and avl tree

    hi iam not able to get the binary tree and avl tree in swings please any one help me
    thanks in advance

    Hi Rastabot.
    If you look closely, it's not that different after all.
    In each step of your recursion you need to do two things: decide whether to keep recursing, and decide what to return to the previous recursive call.
    If you are trying to traverse your entire tree, then your logic to determine when to recurse and when not to is exactly the same as your example.
    What you want to return each time is the number of operators in and below the node in the tree. One useful property of such an expression tree is that all the operands become leaves of the tree, and all other tree nodes are operators. Therefore, if the current node is a leaf node (your subTree == null case in your example), then that node is not an operator and has no operators below it in the tree, therefore you can return zero as the number of operators in or below that node. On the other hand, if the node is not a leaf node (your else case) then it must be an operator, and therefore you would return 1 (for that operator) plus the number of operators in each subtree below that node.
    This is very similar to what you have already posted - mostly, where you have strings you need to replace with integer equivalents.
    I can help with this if you need.
    Mac.
    Edited by: Mac.Coombe on Apr 30, 2009 11:00 PM - made explanation a little clearer

  • Boolean expression pars and evaluate

    Hi
    I need to know if there is code that suggests weather a string is a correct boolean expression or not . if it is, it evaluates it.
    foe example :
    x+1>8 returns true if x=10 e.g
    y-1 is is a wrong boolean expression
    thanx
    Niema

    As far as I know, there is no API that can do something like EVAL in BASIC (which was the last place I saw a feature like this). If you are feeling ambitious, you could write a parser to divide the String into an expression tree, substitute values for variables, and evaluate it.
    But in all probability there is simply another (easier) way of approaching whatever you are trying to do.

  • Problem with referencing nodes

    Hey I am having an odd problem writing a program that uses a Stack to build an expression tree. I have the Stack class set up and my main so that I can locate operators and make a new Node with the operator and put it on the top of the stack, and do the same with the operands. However when I go to push the operator Node (i.e. assign the topOfStack field in my LLStack class to the node I pass) it loses the character in the operator field of my Node. Any idea as to why this happens? I can build the operand stack fine. Here are my classes:
    public class LLStack {
              private IntSLLNode topOfStack;
              public LLStack(){
                   topOfStack=null;
              public boolean isEmpty(){
                   return topOfStack==null;
              public void push(IntSLLNode el){
                   topOfStack= new IntSLLNode(el, topOfStack);
              public IntSLLNode pop(){
                   if(isEmpty())
                        return null;
                   else
                        IntSLLNode top=topOfStack;
                        topOfStack=topOfStack.next;
                        return top;
    }main method
                            Scanner scanString = new Scanner(System.in);
              System.out.println("Enter a postfix expression: ");
              String inputString= scanString.nextLine();
                            LLStack operatorStack = new LLStack();   //create new stacks
                   LLStack treeStack = new LLStack();
                   for(int i=0;i<inputString.length();i++){
                        if(inputString.charAt(i)=='+'|inputString.charAt(i)=='*'|inputString.charAt(i)=='-'){
                             IntSLLNode optr= new IntSLLNode(inputString.charAt(i));
                             operatorStack.push(optr);          
                        else
                             IntSLLNode opnd= new IntSLLNode(Integer.parseInt(Character.toString(inputString.charAt(i))));
                             treeStack.push(opnd);
                        }In other words...when I apply this line
    topOfStack= new IntSLLNode(el, topOfStack);The data in the operator field in "el" does not get assigned to the same field in topOfStack. In Eclipse it shows it as blank. Any ideas why?

    oaklandathletic wrote:
    Fixed it.Funny how explaining a problem for others helps you to work out the solution yourself, isn't it?
    Don't forget that if you decide on programming as a career.
    Winston

  • July TechNet Guru Winners Announced

    Below are the results for last month's Guru Competition - TechNet Guru Awards, July 2014
    The full version can be found here:
    http://blogs.technet.com/b/wikininjas/archive/2014/08/19/the-microsoft-technet-guru-awards-july-2014.aspx
    We can only show the top three winners below, and images are missing, due to forum post length restrictions, but the link above shows the full version.
    A big thank you also to the other authors who did not make the top three of each category.
     BizTalk Technical Guru - July 2014  
    Steef-Jan Wiggers
    Securing BizTalk endpoints leveraging Sentinet API Management Part 1
    Ed Price: "Incredibly epic with great descriptions and diagrams! Another amazing article from Steef-Jan!"
    Sandro Pereira: "Again good job Steef-Jan! Makes me want to try Sentinet"
    TGN: "Stentinet is a great asset to BizTalk. Thanks for sharing such a great article."
    Idar H
    BizTalk Server 2013: How to publish a REST web service with POST
    TGN: "Great guide, and welcome to the TechNet Wiki Idar!"
    Ed Price: "Wonderfully clear instructions and images on this important topic!"
    Sandro Pereira: "A great example."
    Murugesan Mari Chettiar
    BizTalk: Pattern to on-board increasing business partners
    TGN: "Well done Murugesan, great article with a lot of good tips!"
    Ed Price: "Amazing job on the diagram and orchestrations!"
    Sandro Pereira: "A valid pattern, great job Murugesan, but configuration.xml is probably not the best option."
     Forefront Identity Manager Technical Guru - July 2014  
    Scott Eastin
    How to Calculate Manager Reference Value from PeopleSoft SQL View
    PG: "This article is not discussing clasic, traditional way of managing reference/manager attribute. Nor is it discussing why the default way of working might fail. Furthermore this article uses multiple
    un support techniques."
    Ed Price: "Good sample that can be applied to other data as well! Because this article received two negative votes,
    it auto-dropped to Silver. There is an excellent debate about the merit of this unsupported method in the article comments! Thank you to Scott and Peter for adding transparency to this topic!"
     Microsoft Azure Technical Guru - July 2014  
    Mr X
    How to set up Endpoints to Microsoft Azure VMs
    JH: "Well written with a lot of step-by-step pictures!"
    Ed Price: "Another great "How to" from Mr X! Clear instructions and the images help a ton! It would be good to include Azure overview articles and portals in the See Also section. Great job!"
    Mr X
    How to provide a temporary and secure remote access to Microsoft Azure VMs
    JH: "Great article, especially the recommendations at the beginning."
    Ed Price: "There's a lot of great depth in this article! Remote access to Azure VMs is an important topic!"
    saramgsilva
    Datatable design view for Azure SQL Database
    Ed Price: "Good introduction and the arrows help make it super clear what to look for in the images! Important topic and good conclusion!"
    JH: "Short but informative article. It would be useful to mention that some networks (especially corprate networks) block the access to this feature."
     Microsoft Visio Technical Guru - July 2014  
    Durval Ramos
    Reverse Engineering a SQL Server Database using Visio
    SR: "Blog mentions that the "Demo will use Visio 2013" but that's not correct information. This feature is CUT from Visio 2013 and available till 2010."
    AH: "It has good details. I like that it gives step by step process to use Reverse engineering using MS Visio. If Anything if the Author can change the screenshots that are in spanish to englisth that would be great."
    Ed Price: "Great article! Durval addressed the issue and updated the article to reference Visio 2010 instead. You can see the conversation in the article comments. It's great to see authors interact in the article comments and make improvements
    like this!"
     Miscellaneous Technical Guru - July 2014  
    Durval Ramos
    Automating a Data Paging using VBA on Excel
    Ed Price: "Wow! The Introduction is great, there's a ton of information in the "Building" section, the red circles and lines on the images help a ton, a video (in Portuguese), and then the icing parts are the
    References, See Also, and Other Languages section. Amazing job on this article!"
    Richard Mueller: "Great links. A well formatted article."
    TGN: "Great article and well explained, I would maybe try to put some effort in to changing the screenshots to english."
    Mr X
    Hyper-V and DHCP Guard feature
    Richard Mueller: "Great documentation of a new feature. I like the images."
    Ed Price: "Great job on the diagram!"
    TGN: "good article, but a short explaination about what the feature do would make it even better!"
    Mr X
    Hyper-V and Router Guard feature
    TGN: "Great article and explaination!"
    Ed Price: "Good information and use of images! Great job!"
    Richard Mueller: "Great documentation of a new feature."
     SharePoint 2010 / 2013 Technical Guru - July 2014  
    Dan Christian
    How to setup, configure and test SQL 2012 SP1 SSRS with SharePoint 2013
    Ed Price: "This article from Dan is amazing! Fantastic job! Great use of images and great explanations along the way!"
    Benoît Jester: "Another EXCELLENT article by Dan! A complete guide to install SSRS w/ SharePoint 2013!"
    Naveen Sasi
    Retreiving Server Date using SharePoint JSOM
    Jinchun Chen: "Interesting solution!"
    Ed Price: "Good explanation and good to have the See Also section. It would be nice to have the code broken up more and explained. Good job!"
    Benoît Jester: "Thanks for the code,coul be useful!"
    Johnathan Lightfoot
    Web Sensitive Files and SharePoint 2010
    Ed Price: "This is a good article with instructions and images. Thanks for removing the personalization (per the comment from Shanky). It could be improved with headers, a TOC, and a See Also section. The explanations
    near the top are very helpful!"
    Benoît Jester: "Interesting article on "Sensitive Files". Good to know!"
    Jinchun Chen: "Nice"
     Small Basic Technical Guru - July 2014  
    Ed Price - MSFT
    Small Basic Survival Guide
    Michiel Van Hoorn: "Oh the overload!"
    RZ: "Very nicely categorized and organized. Way to go!"
    Nonki Takahashi
    Small Basic: Character Set - Unicode
    RZ: "Very well explained. I wager that many programmers can't quite explain what's unicode and utf-8 :)"
    Michiel Van Hoorn: "Great article on this fundamental element in programming"
    Nonki Takahashi
    Small Basic: Controls
    Michiel Van Hoorn: "Practical topic with good examples"
     SQL BI and Power BI Technical Guru - July 2014  
    Firdous S -MSFT
    Getting Started with Forecasting and Hindcasting in Power View
    PT: "Nice demonstration of this functionality using a simple set of data. Well done."
    MR: "Some formatting issue - I fixed some issue in blank lines and too large pictures, but it should bulleted points should be fixed better"
    RB: "Interesting and thorough walkthrough of the new Forecasting/Hindcasting feature in Power View for Office 365. It's based on an publicly available dataset so you are able to experiment yourself with these features"
    NN: "Nice article with very good images"
    DB: "Very Interesting"
     SQL Server General and Database Engine Technical Guru - July 2014  
    Sean Gallardy
    Cell Level Encryption With Always On Availability Groups
    DB: "Interesting"
    Jinchun Chen: "Excellent."
    Ed Price: "Wow, great code and depth! The down side is with the personal "blog-like" tone, it's harder to collaborate on a Wiki article. (What if someone adds a section or a link to a similar article on a newer version? Is it
    still personal?) Anyway, the content is fantastic!"
    NN: "Very interesting article"
    Samuel Lester: "Great write-up, very informative, and outstanding technique when building up the explanation of the problem."
    DRC: "The article contains lot of information and a very clear explanation of each and every steps. It also provides all the necessary links for related topics. An important change which need to be made is : its not Always ON, its AlwaysOn.
    Shanky
    How to Install SQL Server 2012 SP2 on Standalone Instance of SQL Server
    NN: "Nice article"
    Samuel Lester: "Super informative, this will help a lot of people to walk through the process."
    DRC: "<> This article explains the detailed steps of install and uninstall of Service pack. But i'm not sure whether we need such a detailed explanations for applying service pack. <> Considering the number of SP install issues,
    this article would helpa  lot of users overcome the issue. "
    Ed Price: "This is a great "how to" article! It could be improved with a grammar pass. (Feel free to ask me or others in advance so we have time to help.) While this does duplicate some existing Library content, I like how it
    links to the related articles at the bottom and this does add new depth, which can be very helpful! Another great article!"
     System Center Technical Guru - July 2014  
    Mark Scholman
    Orchestrator – Check System Center VM Snapshots
    Ed Price: "Good explanation, and great image and code formatting! It could benefit from explanations of what the code is doing and from a See Also section that links to related Wiki articles. Great job
    on this article!"
    Mr X
    How to use Orchestrator to automatically recover Website failures
    by checking the HTTP status code 
    Ed Price: "What an epic article! Great job on the descriptions, images, and script! In this case, the table really pops for me and helps me understand the scenario better!"
    Mr X
    How to uninstall or remove SCCM client
    Ed Price: "Good! Short and sweet. Could benefit from a See Also section. Good job!"
     Transact-SQL Technical Guru - July 2014  
    Ronen Ariely
    Transact-SQL: Join Order
    Ed Price: "Great topic with an amazing use of code snippets and images! I love the Conclusions section and the Resources section is fantastic!"
    JS: "Good article, well formatted and a good starting point for someone not being familiar with those pieces."
    Samuel Lester: "Great write-up, explanation, and examples! "
    Richard Mueller: "Great information on an advanced topic. Well explained with good examples and references."
    Jinchun Chen: "Great. " 
    Naomi N
    T-SQL: Find the Peak Hour
    Samuel Lester: "Outstanding! Creative solution, nice comment about the importance of a good design, which would have made this a much simpler task. "
    Richard Mueller: "An advanced topic using new techniques."
    Jinchun Chen: "Nice"
    JS: "Please provide the execution plans of you are already comparing the performance results."
    Ed Price: "Great Problem Definition and good See Also section! Also, great code formatting! It could benefit from explaining what the code's doing more. Great article!"
    Visakh16
    Get Current Fiscal Year Dates
    JS: "Please provide the parameter instead to pass IN current_timestamp instead of assuming the getdate() values."
    Samuel Lester: "Handy little script to add to your T-SQL developer toolbox! Thanks for sharing!"
    Richard Mueller: "I needed better explanation."
    Ed Price: "Great topic and great job on the code! Could benefit from more explanation of what's happening in the code, as well as a See Also section. The explanations at the end are very helpful!"
     Visual Basic Technical Guru - July 2014  
    .paul.
    Simple_database_LogIn_system
    MR: "Great article! Well written. Good note on plain text password. Don't forget to disable controls on hidden panels!"
    Ed Price: "Amazing! The formatting is incredibly clean, and great response in the comments by addressing the encryption concern with a great section in the article! It would also be good to have the code sample available on the MSDN Gallery.
    Fantastic article!"
    Richard Mueller: "A very useful article that deserves to win. Could use more comments in the code. The "See Also" should link to other Wiki's."
     Visual C# Technical Guru - July 2014  
    Eyal Shilony
    A Client/Server Application Using Named Pipes
    Peter Laker: "An old technology that is mistakenly overlooked these days. This is a great article that I hope breathes new life into named pipes."
    Ed Price: "Great article and topic! Great explanations and code formatting. Could benefit from more explanations of what the code's doing, a See Also section, and an Additional Resources section. Great job! A lot of wonderful depth in
    this article!"
    NN: "Good article"
    Jaliya Udagedara
    Writing a Very Basic Dynamic Query using Expression Trees
    NN: "Very nice explanation"
    Peter Laker: "Brilliant article, well worth the read, thanks Jaliya."
    Ed Price: "Fantastic job breaking up and explaining the code snippets. Very easy to follow! Great use of linking to (and leveraging) the MSDN Gallery! This is a great article!"
    Ronen Ariely
    C Sharp: Multi-Types Application
    Ed Price: "Great job on the images, code snippets, and diagram! The Introduction, Case Study, and Resources sections are wonderful! Great article!"
    NN: "Very interesting article"
    Peter Laker: "A nice overview of some basic differences. Thanks Ronen."
     Wiki and Portals Technical Guru - July 2014  
    Durval Ramos
    SQL Server 2014 Portal
    NN: "Great new portal"
    Richard Mueller: "A great portal with useful links."
    Ed Price: "Great job on this portal! It's very important to have a one-stop shop for articles about the latest versions, including SQL Server 2014!"
    Dan Christian
    How to add images to your TechNet Wiki article
    Ed Price: "This is a fantastic end-to-end article, from OneDrive strategies to using tags! Great job on this!"
    NN: "Very useful tips"
    Richard Mueller: "A very well formatted article, on a useful topic."
     Windows Phone and Windows Store Apps Technical Guru - July 2014  
    saramgsilva
    Authentication using Facebook, Google and Microsoft accounts in Universal
    Apps using MVVM
    JH: "Just amazing! Love the amount of code snippets."
    Ed Price: "Incredible depth! The flow diagrams and code formatting help a lot. Great Description section!"
    Peter Laker: "Excellent and vey useful article from a well respected author."
    Saad Mahmood
    Expression Blend - Playing with Sample Data (WPF , Windows Phone)
    JH: "One of my favorite features when working with XAML. Nice to see an article about it."
    Ed Price: "Great formatting and use of images! The final few sections really give a lot of great information! As you see in the comments, Sandro added it to the TechNet Wiki magazine!"
    Peter Laker: "I'm sure we have otehr examples of this in the Wiki, but gratefully received anyway!"
    SubramanyamRaju.B
    WP8.0 vs WP8.1 :All about new package.appxmanifest file at beginners level
    Peter Laker: "Very useful introduction, nicely presented, thanks!"
    JH: "A lot of information and pictures, but needs some reformatting."
    Ed Price: "Good content and great use of images! Could benefit from a grammar pass. Good job!"
     Windows Presentation Foundation (WPF) Technical Guru - July 2014  
    Magnus (MM8)
    WPF: Implementing Custom Authentication And Authorization
    KJ: "good stuff!"
    Ed Price: "Great introduction and depth in the code!"
    Peter Laker: "Epic post from Magnus. Pleny of code, just enough comment."
    Andy ONeill
    Thinking outside the box with the Adorner
    KJ: "good stuff!"
    Ed Price: "Wonderful topic! Could benefit from explanations of what the code's doing. Great job!"
    Peter Laker: "Excellent article, as always, from Andy! I adore adorners!"
     Windows Server Technical Guru - July 2014  
    Mr X
    How to prevent rogue DHCP servers on your network 
    JM: "This is an excellent article on preventing and detecting rogue DHCP servers, nice work."
    Ed Price: "Incredible depth in this article!"
    Richard Mueller: "A great Wiki, with good structure and images. A great topic for system administrators."
    Philippe Levesque: "I like the article, as it's a problem I seen a lot of time in real life (dhcp rogue)" 
    Mr X
    How to get the HTTP status code for a Website running on a specific
    Web server using Powershell
    JM: "This is a good article, thanks again for your contributions."
    Ed Price: "Good explanation!"
    Richard Mueller: "Very useful code, giving administrators a great tool to monitor their web sites. Credit should be given to Lee Holmes."
    Mr X
    How to enable and configure DHCP MAC address filtering
    Philippe Levesque: "Really good documentation ! "
    Richard Mueller: "A very good article. Needs a "See Also" section to reference related Wiki articles."
    JM: "This is a good article on how to enable MAC address filtering."
    Ed Price: "Good article. I especially love the table!"
    A huge thank you to EVERYONE who contributed an article to July's competition.
    Hopefully we will see you ALL again in August 2014's listings?
    If you haven't contributed an article for this month, and you think you can create a more useful, clever and better presented wiki article than the winners above,
    here's your chance! :D
    Best regards,
    Pete Laker
    More about the TechNet Guru Awards:
    TechNet Guru Competitions
    #PEJL
    Got any nice code? If you invest time in coding an elegant, novel or impressive answer on MSDN forums, why not copy it over to the one and only
    TechNet Wiki, for future generations to benefit from! You'll never get archived again!
    If you are a member of any user groups, please make sure you list them in the
    Microsoft User Groups Portal. Microsoft are trying to help promote your groups, and collating them here is the first step.

    Congratulation to all of winners.:)
    Regards,
    Lydia Zhang

  • Logical operators using "AND" and "OR" operators

    I currently have written code which has two for loops to search a user query. I am able to search user queries entered for a simple and composed query. Eg. Simple query can be "Hello" and composed query can be "Hello World".
    What i would like to do now is be able to use logical operators such as "AND", "OR" when searching e.g. "Hello AND World" or "Hello OR World" Once this is done i would like to score the highest point depending on where the query is found.
    Could someone please help me with either giving me some tips of going about this or some starting code and hints. I have attached some code below which explains what i am currently doing to do the simple query.
    private void SearchButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            
    /* Gets the simple query enterted into the text field. It then looks at the strippedFile in memmory */
    long start = System.currentTimeMillis();
    // long elapsed = System.currentTimeMillis() - start;
    String userQuery = SearchTextField.getText();
    StringTokenizer userQ = new StringTokenizer(userQuery);
    String[] brokenStrings = new String[userQ.countTokens()];
    int counter2 = 0;
    while (userQ.hasMoreTokens()) {
    String moreStrings = userQ.nextToken();
    brokenStrings[counter2] = moreStrings;
    counter2++;
    int Simplematches = 0;
    for (int i = 0; i < strippedFile.length; i++) {
    String LongCurrentLine = strippedFile;
    StringTokenizer st = new StringTokenizer(LongCurrentLine);
    String[] currentline = new String[st.countTokens()];
    int counter = 0;
    while (st.hasMoreTokens()) {
    String moreStrings1 = st.nextToken();
    currentline[counter] = moreStrings1;
    counter++;
    highlighter.highlight(HTMLOutputTextArea, userQuery);
    for (int j = 0; j < brokenStrings.length; j++) {
    for (int k = 0; k < currentline.length; k++) {
    if (brokenStrings[j].equalsIgnoreCase(currentline[k])) {
    long elapsed = System.currentTimeMillis() - start;
    Simplematches++;
    String output = "\"" + currentline[k] + "\" was found on line " + (i + 1) + "." + " At postion " + (k + 1) + " and took " + elapsed + " milliseconds." + " Found " + Simplematches + " matches" + "\n";
    //String output = "\"" + currentline[k] + "\" was found on line " + (i + 1)+ "." + " At postion " + (k + 1) + " Found "+ Simplematches+ " matches"+ "\n";

    jschell wrote:
    london_guy86 wrote:
    jschell wrote:
    Not clear what you search, but....
    First you need to specifically define the syntax. For example what does the following mean?
    a OR b AND c OR d
    Once you do that then you parse the input to create an expression tree. Then you write an interpreter to run the expression tree.Is there any chance you could give me a starter code or soe sources i could look at. I really dont understand how to go about doing what you have mentioned. As in i have declared the syntax at the moment and i am then using the replaceAll() and calling in what i have declared. with empty strings.
    Is this what you mean?Hard to say since I don't understand your statement.
    There are three parts
    1. Parse the expression.
    2. Interpret the expression
    3. Do the "search", this is actually part of 2 however it should be possible to implement some or all of it separate from 1 and 2.
    Do NOT mix the three parts until you are ready to mix them.
    Your posted code is mixing them.
    Presumably what you posted is mostly search. So to start re-write JUST the search code as a class.
    However you can't really do that until you define what the expressions do.After doing everything you mentioned do you think it would be hard to get a score on the best match search found?
    If not could you also give me some tips towards that if you know any.
    Thanks

Maybe you are looking for