Thread: help! Imp

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    39

    Exclamation help! Imp

    My problem is as below:

    I have a formula say b= a/b+c*d/d+e*c/d-f*h/g etc (can be any such huge formula)

    and i need to rename the subformulas so that the formula size becomes smaller.Also it is better if positive/negative subformulas are grouped together.

    i.e say i have a cut of of number of unique elements in a subfrmula to be 3, then i need to the above formula as:

    b=p+q
    p=a/b ( The number of elements can less than or equal to 3)
    q=c*d/d+e*c/d ( the number of unique elements is only 3 i.e c,d,e)
    r=-f*h/g

    My current approach to solving the problem and where Iam stuck:

    I have used 2 stacks called negative and positive stack which seperates the positive and negative subformulas as:

    in thsi case Positive stack has :a/b , c*d/d
    negative stack :f*h/g.

    Also I have written a function that counts the unique elements in a subformula.

    Now I need to be able to group the subformulas, where Iam facing the problem, can anyone direct me as to how to go about doing the same given the current implementation that I have done?

    Thanks

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    What do you think you mean by "group the subformulas"? So far as I can tell, you have already done so by having two separate stacks, one for added subformulas and one for subtracted subformulas.

  3. #3
    Registered User
    Join Date
    Jun 2009
    Posts
    39
    Hi,

    Grouping the subformulas means, joining the sperated subformulas( as in + ve elements and negative elements) back so that the number ofunique elements in the final formula is less or equal to the set cut off of 3.

    thanks for your effort

  4. #4
    Registered User
    Join Date
    Jun 2009
    Posts
    39
    Please help

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by doubty View Post
    Please help
    Why is this any more difficult than
    Code:
    while number of needed subformulas > 3
        group three subformulas together
    You just then need a way to "mark" the sub-subformulas as "not appearing in the final answer".

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. complex class imp?
    By stabu in forum C++ Programming
    Replies: 3
    Last Post: 03-12-2009, 04:06 PM
  2. Battle Ship AI
    By IdioticCreation in forum Game Programming
    Replies: 10
    Last Post: 01-05-2007, 11:22 PM
  3. how to display jpeg image using borland C++ 5.02
    By gaurav07 in forum Windows Programming
    Replies: 2
    Last Post: 05-26-2005, 02:42 AM