| Author |
Resolving Boolean Expression
|
Vj Kamath
Greenhorn
Joined: Nov 19, 2004
Posts: 15
|
|
Given this input, i have to write a program to generate different possible combinations. ( ( ( A | B | C | D | F | G | E | H | I ) & J ) | ( ( A | D | H ) & L ) | ( ( B | G ) & M ) | ( F & K ) ) result should be AJ OR BJ OR CJ OR DJ OR EJ OR FJ OR HJ OR IJ OR AL OR DL OR HL OR BM OR GM OR FK I have found programs that use stacks to convert from infix to postfix ...etc. But this program is different. This needs to resolve the string.
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Hmmm.... Sounds like a school assignment.. If this is really about string parsing, then the regexp tools in j2sdk1.4 and up can make short work of this task. 1.) Remove white space. 2.) Split the string into groups on ")|(" (lame but efficient). 3.) For each group, split the groups into pairs on "&". 4.) Remove all non alpha characters (caps in this case). 5.) For each char in the left side of the pair, print char plus right side of pair. Like this: Now, if this is for a "Data Structures" or "Compiler" class as the title suggests, such an approach would probably get you a failing grade. Go back and look a the stack approach. [ December 31, 2004: Message edited by: Ben Souther ]
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
 |
|
|
subject: Resolving Boolean Expression
|
|
|