Problem about tree

Hi,everyone,I am just new to java.And now I got a problem with storing the following expression into a binary tree:
The expression is like: ((a/b)+((c-d)*e)) in a txt file.
so,what i want to do is to store variable and operation(+-*/)into a tree.And calculate that by using preorder traversal such as
+(/(a,b),*(-(c,d),e)).However,i even don't know how to start coding.
+
a b - e
c d
the data i want to be stored in a tree will be like above.Then,I need to use inorder traversal to display the final formula like ((a/b)+((c-d)*e))
Please get me some help.Thank you very much from everybody!

Hi,
don't have any code to answer your question but here's what I'll suggest:
1) Define a class whose job will be to represent a simple expression. A simple expression is defined by '<exprX> <operator> <exprY>'. In this class, you must include a way to distinguish expressions from variables.
With your sample, there would be N expressions:
expr1 = (a / b)
expr2 = (c - d)
expr3 = (expr2 * e)
expr4 = (expr1 + expr3)
2) Define a class whose job will be to parse the formula, and create the expressions. The idea would be to find operators, and create expressions on left / right sides of the operators (I agree, it's a little harder than that, but I only have ideas right now...)
Also you'll have to store some kind of 'level info', perhaps here should be the use of the tree, keeping track of each level of computation (expr4 will be at top level, then expr3 under it, then expr2 and expr1)
Use of recursion seems evident here (and seems simple to apply to a tree structure):
- first parse will give expr4 = (expr1 + expr3) (both have to be parsed again)
- second parse will occur on expr1 = (a / b) and expr3 = (expr2 * e) (then expr3 has to be parsed)
- third parse will occur on expr2 = (c - d)
That's my two cents... sorry missing time for more help, try starting with this I'll follow the thread and help more if I can!
Regards.

Similar Messages

  • A problem about tree height

    hi all,
    i have created a tree in my BSP page and i hard code the content of the tree like
    CLEAR wa_tab.
    level 1 - Knowledge and help
    wa_tab-treeid = 'support_application'.
    wa_tab-parentid = ''.
    wa_tab-childid = 'HELP'.
    wa_tab-text = 'Self Help'.
    APPEND wa_tab TO gt_tab.
    but i want to make the size of tree higher, i coding like below
    <htmlb:tree title = "<%= otr(/SPN/SMB/VAR05P01_04) %>"
    showTitle = "true"
    id = "support_application"
    table2 = "<%= gt_tab %>"
    width = "100%"
    height = "120%" />
    but nothing happened ,
    i added a empty line in the tree table but there is a icon before the empty tree node ,
    who can give me a hand ?

    a htmlb:tree occupies as much space as required to render the nodes, if you want it to occupy more space (height) you have to set some nodes expanded. the height property of the tree dosent make any difference
    Regards
    Raja

  • An old and difficult problem about "UnsatisfiedLinkError"

    Hi dear all,
    I have been struck with the problem about "UnsatisfiedLinkError". I have a c++ class HelloWorld with a method hello(), and I want to call it from within a java class. In fact, I have succeeded in calling it on the windows platform. But when I transfer it to linux, the error "UnsatisfiedLinkError" comes out. I have tried to take the measures as Forum has suggested, but it failed.
    The source code is very simple to demonstrate JNI.
    "HelloWorld.h"
    #ifndef INCLUDEDHELLOWORLD_H
    #define INCLUDEDHELLOWORLD_H
    class HelloWorld
    public:
    void hello();
    #endif
    "HelloWorld.cpp"
    #include <iostream>
    #include "HelloWorld.h"
    using namespace std;
    void HelloWorld::hello()
    cout << "Hello, World!" << endl;
    "JHelloWorld.java"
    public class JHelloWorld
    public native void hello();
    static
    System.loadLibrary("hellolib");
    public static void main(String[] argv)
    JHelloWorld hw = new JHelloWorld();
    hw.hello();
    "JHelloWorld.cpp"
    #include <iostream>
    #include <jni.h>
    #include "HelloWorld.h"
    #include "JHelloWorld.h"
    JNIEXPORT void JNICALL Java_JHelloWorld_hello (JNIEnv * env, jobject obj)
    HelloWorld hw;
    hw.hello();
    All the files are in the same directory and all the processes are under the dirctory:
    1. javac JHelloWorld.java
    2. javah -classpath . JHelloWorld
    3. g++ -c -I/usr/java/jdk1.3/include -I/usr/java/jdk1.3/include/linux JHelloWorld.cpp HelloWorld.cpp
    4. ld -shared -o hellolib.so *.o
    5. java -cp . -Djava.library.path=. JHelloWorld
    Exception in thread "main" java.lang.UnsatisfiedLinkError: no hellolib in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1349)
    at java.lang.Runtime.loadLibrary0(Runtime.java:749)
    at java.lang.System.loadLibrary(System.java:820)
    at JHelloWorld.<clinit>(JHelloWorld.java:7)
    Tried another measure:
    i) export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
    ii)java -cp . JHelloWorld
    The same error came out as above.
    I really don't know what is wrong with it.
    Would you like to help me as soon as possible?
    Thanks.
    Regards,
    Johnson

    Hi Fabio,
    Thanks a lot for your help.
    It is very kind of you.
    Regards,
    Johnson

  • A problem about calling Labview vi in VB

    Hi all:
    I meeting a problem about data transfer and parallel operation between VB and Labview.
    Actually, I want develop a VB program, in which, the Labview VI can be called and corresponding parameters can be transferred to Labview. and then, I also can operate my system by VB program at same time. something like parallel operation (VB and Labview program).
     But the question is :
    1.   If I use "Call" method of ActiveX in VB,  and the LabVIEW subvi is not stopped (for example, a loop structure), I can not do  parallel operation on VB program. The error message is "other application is busy" which is attached below. The sample codes is also attached.
    2.   I tried to use other methods like "OpenFrontPanel" and "Run", but I am not sure how to transfer the parameter??
    3.  Then I tried to use "SetControlValue" to set the parameters, but there is a error " := expected", which is very strange, because the statement  I wrote is followed with the help documents [ eg: VI.SetControlValue ("string", value)], why it is still need a "=" ??
    Does anybody know something about it? Thanks a lot
    Message Edited by hanwei on 11-07-2008 03:18 PM
    Attachments:
    vb_labview_error_message_1.JPG ‏14 KB
    VB_to_LV.zip ‏10 KB

    I sure hope OP has solved it by now.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • HT201210 hi everyone, i have a problem about my iphone 4S, doesn't work with wifi connection and bluetooth since upgrade to the IOS 7.0.3. Can anyone can help me tosolve this problem?????Thank's regards paulus

    hi everyone, i have a problem about my iphone 4S, doesn't work with wifi connection and bluetooth since upgrade to the IOS 7.0.3. Can anyone can help me tosolve this problem?????Thank's regards paulus

    Try the suggestions here to see if they resolve your problem:
    http://support.apple.com/kb/ts1559
    If these don't work you may have a hardware problem. Visit an Apple store for an evaluation or contact Apple Support.

  • Problem about Handling of Empty Files in File Adapter

    Hello everyone,
    NetWeaver 2004s --- XI
    In Sender i have a File Adapter.
    Now i meet a problem about Handling of Empty Files. When i send empty file, but don't cerate a leer message.
    I have seen following text in help document. But in adapter configuration i can not find the correspond parameter.
    can you give me some tips?
    Thx in advance
    best regards
    Yaning
    SAP Help Document über File Adapter
    +Handling of Empty Files
    Specify how empty files (length 0 bytes) are to be handled.
    &#9675;       Do Not Create Message
    No XI messages are created from empty files.
    The files are processed according to the selected Processing Mode.
    For example, if the processing mode is Delete, empty files are deleted in the source directory.
    &#9675;       Process Empty Files
    XI messages are created with an empty main payload.
    The files are processed according to the selected Processing Mode.
    &#9675;       Skip Empty Files
    No XI messages are created from empty files.
    Empty files are skipped and remain in the source directory.+
    Help Docu

    hi,
    it's available since Sp19 for XI 3.0
    and the corresponding SPS fpr XI 7.0
    http://help.sap.com/saphelp_nw04/helpdata/en/44/f565854b7341e6e10000000a1553f6/frameset.htm
    so probably you need to install the new SP
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

  • Problem about sales order stock stock transfer and batch determination

    Hi, experts, I get a problem about sales order stock stock transfer and batch determination.The following is the current situation of my system:
      In OMCG I assigned search procedure ME0001 to both 311 and 311 E and ticked check batch. After that, I found  that if iI need to tranfer unrestricted-use material from storage location 1000 to 2000 with movement type 311, I just need to input * at the field batch, then the system will display all of the available batches. But for the transferring of sales order stock with movement type 311 E, after I input * at the batch field, no batch is displayed and there is also no message from the system.
      Can anybody help me? Is there anything else I need to do? Thanks very much.

    I think my question is not clear, actually I tried 562 E , 411 E and 413 already. all the transaction looking for the sales order but unfortunatly the sales order is deleted  from SAP.

  • Hello apple I have the problem with my iPhone and my friends have this problem too. My iPhone have the problem about calling and answer the call. When I use my iPhone to call I can't hear anything from my iPhone but the person that I call can answer it bu

    Hello apple
    I have the problem with my iPhone and my friends have this problem too.
    My iPhone have the problem about calling and answer the call. When I use my iPhone to call I can't hear anything from my iPhone but the person that I call can answer it but when answer both of us can't hear anything and when I put my iPhone to my face the screen is still on and when I quit the phone application and open it again it will automatic call my recent call. And when my friends call me my iPhone didn't show anything even the missed call I'm only know that I missed the call from messages from carrier. Please check these problem I restored my iPhone for 4 time now in this week. I lived in Hatyai, Songkhla,Thailand and many people in my city have this problem.
    Who have this problem??

    Apple isnt here. this is a user based forum for technical questions. The solution is to restart, reset, and restore as new which is in the manual after that get it replaced for hard ware failure. if your within your one year warranty its replaced if it is out of the warranty then it is 199$

  • Problem about updating to Mac OS X 10.5.3

    Hi there,
    I just bought my Macbook two months ago. I encounted a problem about updating it to the latest version of MAC OS X. The system reminded me to restart, I proceed. Everythig looked just fine until a poping up window shown "Mac OS X 10.5.3 pacakage can not be validated". Dose anyone know what did that mean? How can I update my little mac?

    Hi Hummer,
    First, welcome to Apple discussions.
    To answer your question, your computer checks all downloaded updates before installing them. It does this to make sure it's got the entire file and that the update will install correctly. The fact that validation fails on your machine probably means the file did not download correctly.
    To install 10.5.3, simply go to this website, download the "10.5.3 combo update" and then run it on your Mac: http://www.apple.com/support/downloads/

  • Hardware diagnostic shows me a problem about charging battery. What about it ?

    Hi.
    I bought a MacBook Pro retina 13', mid 14. on last december, and after almost a month I did the hardware test of apple as the Technic support says, and this hardware test shows me a problem about charging battery, so, I wanna know what about it, is it normal ? or is it a battery problem or is it a problem about the Current adaptador ? Thank your for your answers.

    Could be battery, could be adaptor, could be the computer itself.  You will have to take it in for testing.  Fortunately, you are still under warranty.

  • The problem about vrrp

    Dear all,I have a problem about vrrp,my core switch is cisco 3750x and huawei S5700-28C-EI, after I configured vrrp between them,the switch log got the error problem as follow:
    *Jan 11 00:01:43.111: %VRRP-6-STATECHANGE: g1/0 Grp 3 state Backup -> Master
    *Jan 11 00:01:43.111: VRRP: tbridge_smf_update failed
    *Jan 11 00:01:44.187: VRRP: Advertisement from 10.252.200.34 has an incorrect group 10 id for interface g1/0
    *Jan 11 00:01:46.539: VRRP: Advertisement from 10.252.200.36 has an incorrect group 10 id for interface g1/0                
    *Jan 11 00:01:50.323: VRRP: Advertisement from 10.252.200.34 has an incorrect group 10 id for interface g1/0
    *Jan 11 00:01:51.707: VRRP: Advertisement from 10.252.200.36 has an incorrect group 10 id for interface g1/0
    *Jan 11 00:01:52.079: VRRP: Advertisement from 10.252.200.34 has an incorrect group 10 id for interface g1/0
    *Jan 11 00:01:53.079: VRRP: Advertisement from 10.252.200.34 has an incorrect group 10 id for interface g1/0
    If cisco and huawei cannot interconnect with each other?

    Can you post the interface config from the huawei and cisco device?
    HTH,
    John
    *** Please rate all useful posts ***

  • A problem about Chinese encoding

    When i access portal by SSL,I find one or two problems about encoding.
    reshow these problems:
    1. Locale be set to Chinese(zh_CN)
    2. access portal by SSL
    3. Administration/create portlet
    Then the popup window's title will show a bad encoding.
    otherwise,if i search chinese, then only have bad encoding shown in the searchbox and i can't get anything.
    MY running enviroment:
    windows 2003
    plumtree foundation v6.0
    plumtree publisher v6.2
    tomcat 5.0.58 with jre_1.4.2.08
    MSSql 2000 sp4
    and I have tried other BEA ALUI newer version,I can get these problems.
    I'm appreciated for any help.

    ANSI 0xFF is NBSP. NBSP in Unicode is 0x00A0... so neither 0x00FF (which is �) nor 0xF5F8 (which is in the "private use" range) is correct. Something really weird is going on.We are talking about CP1252 and in CP1252 0xFF is �
    (see http://czyborra.com/charsets/iso8859.html for example) and thus is \u00FF correct.
    btw. I would never use windows notepad as reference application.

  • A problem about EAX

    A problem about EAXX We have some problem in our development when using "Creative OpenAL SDK . (ver 3.03)". We create "OpenAL device" using "Generic Software"
    and play audio with EAX2.0. But the EAX effect works on one computer while it doesn't work on another one. Followings are the two computers' configuration:
    The computer which works well with EAX:
    Operation system: Windows XP SP3
    Motherboard chipset: Intel i945G
    Sound card: Creative Sound Blaster Audigy Digital Deluxe
    OpenAL.dll version: 6.4.0357.22
    Wrap_oal.dll version: 2..8.
    The computer which doesn't work with EAX:
    Operation system: Windows XP SP3
    Motherboard chipset: Intel i945GC
    Sound card: Creative Sound Blaster Audigy Digital Deluxe
    OpenAL.dll version: 6.4.0357.22
    Wrap_oal.dll version: 2..8.

    Hello gozhu_g,
    I suggest getting in touch with the developers on your inquiry. Here's their site.

  • Problem about space management of archived log files

    Dear friends,
    I have a problem about space management of archived log files.
    my database is Oracle 10g release 1 running in archivelog mode. I use OEM(web based) to config all the backup and recovery settings.
    I config "Flash Recovery Area" to do backup and recovery automatically. my daily backup schedule is every night at 2:00am. and my backup setting is "disk settings"--"compressed backup set". the following is the RMAN script:
    Daily Script:
    run {
    allocate channel oem_disk_backup device type disk;
    recover copy of database with tag 'ORA$OEM_LEVEL_0';
    backup incremental level 1 cumulative copies=1 for recover of copy with tag 'ORA$OEM_LEVEL_0' database;
    the retention policy is the second choice, that is "Retain backups that are necessary for a recovery to any time within the specified number of days (point-in-time recovery)". the recovery window is 1 day.
    I assign enough space for flash recovery area. my database size is about 2G. I assign 20G as flash recovery area.
    now here is the problem, through oracle online manual, it said oracle can manage the flash recovery area automatically, that is, when the space is full, it can delete the obsolete archived log files. but in fact, it never works! whenever the space is full, the database will hang up! besides, the status of archived log files is very strange, for example, it can change "obsolete" stauts from "yes" to "no", and then from "no" to "yes". I really have no idea about this! even though I know oracle usually keep archived files for some longer days than retention policy, but I really don't know why the obsolete status can change automatically. although I can write a schedule job to delete obsolete archived files every day, but I just want to know the reason. my goal is to backup all the files on disk and let oracle automatically manage them.
    also, there is another problem about archive mode. I have two oracle 10g databases(release one), the size of db1 is more than 20G, the size of db2 is about 2G. both of them have the same backup and recovery policy, except I assign more flash recovery area for db1. both of them are on archive mode. both of nearly nobody access except for the schedule backup job and sometime I will admin through oem. the strange thing is that the number of archived log files of smaller database, db2, are much bigger than ones of bigger database. also the same situation for the size of the flashback logs for point-in-time recovery. (I enable flashback logging for fast database point-in-time recovery, the flashback retention time is 24 hours.) I found the memory utility of smaller database is higher than bigger database. nearly all the time the smaller database's memory utility keeps more than 99%. while the bigger one's memory utility keeps about 97%. (I enable "Automatic Shared Memory Management" on both databases.) but both database's cup and queue are very low. I'm nearly sure no one hack the databases. so I really have no idea why the same backup and recovery policy will result so different result, especially the smaller one produces more redo logs than bigger one. does there anyone happen to know the reason or how should I do to check the reason?
    by the way, I found web based OEM can't reflect the correct database status when the database shutdown abnormally. for example, if the database hang up because of out of flash recovery area, after I assign more flash recovery area space and then restart the database, the OEM usually can't reflect the correct database status. I must restart OEM manually to correctly reflect the current database status. does there anyone know in what situation I should restart OEM to reflect the correct database status?
    sorry for the long message, I just want to describe in details to easy diagnosis.
    any hint will be greatly appreciated!
    Sammy

    thank you very much, in fact, my site's oracle never works about managing archive files automatically although I have tried all my best. at last, I made a job running daily to check the archive files and delete them.
    thanks again.

  • A switch on/off problem about the relay in a loop

    hi group:
    I am developing a project based the Ni-sci-1160. Now I meet a problem about switch on/off in a loop.
    for example:  I creat a loop, and continually check a boolean. if the boolean is true, then the realy is closed, otherwise the relay is open. The problem is when I make the boolean is true,  the corresponding relay is not always on,  but just on-off, on-off,on-off.  I don't know why? Is there any good idea to fix it?
    the easy example codes is attached here , thanks for you help.
    Attachments:
    relay_problem.vi ‏19 KB

    Try moving that first DAQmx function out of the while loop.  Since it is called switch set and Reset, I'm guessing it is resetting the status of the switch every iteration of the while loop which probably means setting it back to false.  It looks like an initialization type of function which means it should only be run once.

Maybe you are looking for

  • Disabling the Mail Application?

    I'm running 10.6.8 on an original 2006 Macbook Pro.  I've ALWAYS had a problem with my "Mail" application!!!  I NEVER use it!!!  I actually HATE it!!! But I LOVE using the "Calendar" application. My problem occurs when my turning on my computer and I

  • ME 8 SDK on Mac OS X?

    I see this was asked a while back (Is the Java ME 8 SDK only for Windows?), but since this was several months back, is there any news whether there will be a Mac OS X version of the ME 8 SDK? Thanks, Kevin

  • How do I install AE CS6 11_LS7 onto MAC OSX Yosemite 10.10.1 since it won't open?

    I am trying to install After Effects CS6 11_LS7 onto MAC OSX Yosemite 10.10.1, but it won't open? I can't find a later download for AE CS6 that may fix this problem. What should I do?

  • HT4539 How cain I purchase an APP in a previous free APP without put my ID apple?

    My daughter ask me to download an app, a game called, THE LITTLEST PET SHOP, on the last March 2rd.  It is a free one!  She became very happy playing this app. But unfortunately, on Sunday, I received an email about my invoice in Itunes Store, as I a

  • Failed to activate coldfusion scheme

    Brand new install of CFB 2, I get this error "Failed to activate coldfusion scheme". The outline panel throws: ""Failed to activate coldfusion scheme"" (below is the stack). I found something about Aptana causing an issue (http://developertips.blogsp