Any Suggestions?

I know you have seen tons of these questions from students, but mine is a bit different. I am not asking how to do the convertions, I am asking how to remove parens. I have partically done some of the paren removal, but as you can see from my output below, I still have a spare in locations that really don't need them. I am wondering if I need to do a second run through the expression and "strip" parens or not.
Any ideas, suggestions or hints would be greatly appreciated.
Infix and Postfix Expressions
Author: C. K. Bales
Copyright 2002
Starting Infix to Postfix Expressions:
Infix Expression: (A+C)*D
Postfix Expression: AC+D*
Infix Expression: A+C*D
Postfix Expression: ACD*+
Infix Expression: Z+D-F*G
Postfix Expression: ZD+FG*-
Infix Expression: (Z+D-F)*G
Postfix Expression: ZD+F-G*
Infix Expression: A^3*B^2*C^1
Postfix Expression: A3^B2^*C1^*
Infix Expression: A-B^C
Postfix Expression: ABC^-
Starting Postfix to Infix Expressions:
Postfix Expression: XYZ+*
Infix Expression: X*Y+Z
Postfix Expression: KJ*L/
Infix Expression: (K*J)/L
Postfix Expression: ACD*+
Infix Expression: A+C*D
Postfix Expression: ZD+F-G*
Infix Expression: ((Z+D)-F)*G
End of Expressions in File.
Thank you for using our software.
The two that I would like to strip the parens from are (K*J)/L and ((Z+D)-F)*G.
They should read K*J/L and (Z+D-F)*G.
The code that currently handles removing the parens is:
if (!stack.isEmpty() && isOperand(temp.toString())) {
x = (String)stack.pop();
y = (String)stack.pop();
together = "(" + y + postfix + x + ")";
infix += together;
infixExpr = infix;
together = "";
infix = "";
} else {
x = (String)stack.pop();
y = (String)stack.pop();
together = y + postfix + x;
infix += together;
infixExpr = infix;
together = "";
infix = "";
} //end if
stack.push(infixExpr);
Should I run a deeper check than that? I really don't want to make it more complicated than it needs to be...like I said, any ideas, suggestions, hints would be greatly appreciated...thanks!
CK

Let's see if I get this right. I am currently taking the Data Structures class and Big(O) and I have not been getting along terribly well. I am serverly dyslexic and the Data Structures text book uses very long and complicated string computations to result in the Big(O) notation. I have re-read those chapters several times to try to get it down for the final.
Ok, ACIDS is the mechinism used to test which ADT is best to use:
Add
Change
Inspect
Delete
Sort
Arrays -
They have a fixed size and give the programmer the advantage of the [] sub-brackets to access data items within the array.
To insert it is n-1 moves
To delete it is n-1 moves
To insert in order it is n-1 moves
And you can go straight to any point in the array.
Current sort algorithms work with an array
Linked Lists -
Insert at front of list is n
Delete from front of list is n
Dynamic size
Add in order is n links
Delete a specific link is n links
Current sort algorithms don't work with a Linked List
Big(O) of a Linked List is on most cases n
Big(O) of an Array on most cases is n^2.
When is it best to use one over the other?
If there will not be a lot of changes done to the data, and you need instant access to each element of data, use an array.
If there will be a great many changes done to the data, and instant access isn't overtly necessary, use a Linked List.
Which uses less memory as they "increase". To increase an Array you must create a new array and copy the old one into it. Such things as ArrayLists automatically double the size of the array as you add new elements to it. Both use a lot of overhead in maintaining a contiguious segment of memory to hold the information within them.
A Linked List doesn't need contiguious memory, and only increases by one each time a link is added, therefore it doesn't use a lot of memory.
Both can be fast for small amounts of data, but over time, a Linked List will be faster than an array with extremely large amounts of data.
Though I may be wrong on the Big(O) part, I have been reading my homework and have gotten full points on my other three assignments in this class so far.
<g>
Thanks, that was fun!
CK

Similar Messages

  • I cannot open Pages from the app or from a saved document on the desk top.  I get an error: "The application Pages cannot be opened  -1712"  Any suggestions?

    I cannot open Pages from the app or from a saved document on the desk top.  I get an error: "The application Pages cannot be opened  -1712"  Any suggestions?

    The following previous discussion has a solution that worked for a variety of people with the -1712 error on a variety of applications and may help: The application Safari can't be opened -1712

  • HT5012 I am having difficulty XMIT/REC text messages to family members using Android phones?  I have a 3GB data plan and all switches and buttons are set properly.  Any suggestions?

    I am having difficulty XMIT/REC text messages to family members using Android phones?  I have a 3GB data plan and all switches and buttons are set properly.  Any suggestions?

        Hello APVzW, we absolutely want the best path to resolution. My apologies for multiple attempts of replacing the device. We'd like to verify the order information and see if we can locate the tracking number. Please send a direct message with the order number so we can dive deeper. Here's steps to send a direct message: http://vz.to/1b8XnPy We look forward to hearing from you soon.
    WiltonA_VZW
    VZW Support
    Follow us on twitter @VZWSupport

  • I've just upgraded to IOS 7.0 on my iPhone 5 and the calendar is horrible!  I want to be able to see the who day at a glance not a few hours.  Does anyone have any suggestions?

    What's happened to the calendar in IOS 7.0?  I would like to be able to see the whole day at a glance not just a few hours.  Any suggestions?

    I know what it looks like and what it does.  I need to be able to see the whole day!  A few hours is not helpful for knowing whats ahead.  I don't want to scroll I just want to be able to look at a glance.  Does anyone have any helpful suggestions.

  • In ical I just added new calendars to a pre-existing calendar group, I can make events with these calendars, but not reminders, any suggestions?

    in ical I just added new calendars to a pre-existing calendar group, I can make events with these calendars, but not reminders, any suggestions?

    Hi,
    Lion has changed the way reminders (todos as was) work. They now seem to need to be in a seperate calendar.
    In iCal open the File menu and select New Reminder List... and select where to put it.
    Best wishes
    John M

  • Ok so we bought an ipodtouch for my daughter and when she connected to the computer all of a sudden she lost all her pics and she can no longer connect to the app store on  her ipod.. any suggestions why and what can be done?

    ok so we bought an ipod touch for my daughter and when she connected it to the computer after she downloaded itunes, she was asked if it was her ipod or a new one, so she clicked on her ipod and lost all her recent pics plus is unable to locate the app store on her safari on her ipod touch. any suggestions as to what went wrong or what should be done ? should we restore or what?
    much appreciated if there is anyone else who had this happen to them.

    - The iPod got erased since it sounds iTunes identified that the iPod has been synced with another computer and she said yes to making this computer her syncing computer. It could also she restored the iPod from the backup of another iPod, iPhone or iPad that was in iTunes. If in iTunes you go to Preferences>Devices is there a backup listed for her iPod with a date/time when she first connected the iPod to the computer. If so then restore the iPod from that backup.
    iOS: How to back up
    Note synced media like apps and music are not included in the backup,
    You can redownload iTunes purchases by:
      Downloading past purchases from the App Store, iBookstore, and iTunes Store
    - Regarding the App store. The App store is not in Safari. It is a separate app. Also, could the Apple store be hidden by Restrictions? Settings>General>Restrictions. Further, can you find the App store via the Spotlight search on the iPod?

  • I have 3 older ext. hard drives that I've utilized many times. Today while searching for old files, one of the three is no longer recognized by my PowerMac.  Any suggestions?

    I have 3 older ext. hard drives that I've utilized many times. Today while searching for old files, one of the three is no longer recognized by my PowerMac. The drive is not listed in Disk Utility.  Any suggestions?

    Is the computer in you equipment line:
    Dual Core Intel Xenon
    (which is not a PowerMac but a Mac Pro) the one you are asking about, or do you have an older PowerMac?
    If a Mac Pro, their forums are here:
    Mac Pro
    and, as Mac Pros have a totally different architecture from the pre-2005 Macs this forum covers, you may not have the same issues that can affect the older models. If someone didn't notice your equipment line, you could get advice that doesn't apply.
    If you really have a pre-2005 PowerMac, read on.
    If the stubborn external is USB and does not have its own power brick (i.e., it gets power only from the computer's UBS ports--"bus powered"), it may not be getting enough power. As electric motors age, they can demand more power than when new, and the power available on any USB port is limited.
    The typical workabouts to making a computer recognize an aging, bus-powered USB drive are:
    Get a powered USB hub (has its own power brick
    Get a "Y" USB cable: 1 Meter USB 2.0 A to 5 Pin Mini B Cable - Auxiliary USB "Y" Power Design for external hard drives.
    The second gets power from two USB ports on the computer and often that's enough.
    Remember that the USB ports on your keyboard seldom provide enough power even for a thumb drive, so be sure to use the USB ports on the back of the computer.

  • I own the very first ipod and can no longer be updated or synced any suggestions to get it back up and running, has just decided to stop 2015

    I own the very first ipod and can no longer be updated or synced any suggestions to get it back up and running, has just decided to stop 2015

    Try:                                               
    - iOS: Not responding or does not turn on           
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try another cable                     
    - Try on another computer                                                       
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
      Apple Retail Store - Genius Bar                              
    It could be that the battery has died

  • I use my ipod for audible books downloads. In the past I have been able to move books back and forth from library to ipod according to what I was listening to.  I can no longer retreive books in the library. Any suggestions?

    I use  my 6th generation Ipod strictly for Audible downloads.  In the past, I have been able to move titles back and forth from the Ipod and my Itunes library, to control the amount books on the ipod. Recently, an exclamation mark has appeared next to the titles as I try to transfer to the ipod, and the book does not transfer.  Any suggestions on how to regain access to my purchased library? 

    1. You did not get an error message telling you that your iPhoto library was getting full. You got a message telling you that your HD was getting full, right?
    OS X needs about 10 gigs of hard drive space for normal OS operations - things like virtual memory, temporary files and so on.
    Without this space your Mac will slow down as the OS hunts for space on the disk, files will be fragmented, also slowing things down, apps will crash and the risk of data corruption - that is damage to your files, photos, music - increases exponentially.
    Your first priority is to make more space on that HD. Nothing else can be done until you do.
    Purchase an external HD and move your Photos and Music to it. Both iPhoto and iTunes can run perfectly well with the Library on an external disk.
    Your Library has been damaged from being run on an overfull disk.
    How much free space on it now?

  • No Disk error-Any suggestions?

    Using Elements 7 with Windows 7.  Get the following error when I open the program "There is no disk inthe drive. PLease insert a disk into the drive\Device\Harddisk6\DR6."  Any suggestions to get rid of it.  The program works but the error box is annoying.

    Hi there,
    Its nice to learn that PSE7 is working on Win7 because PSE7 has not been certified to work on Win7.
    However, on searching on the Internet, I learned that many people are observing this error and the main reason indicated is due to being low on memory resources.
    Try resetting the preferences from Organizer.
    Thanks/ Tarun

  • HT4528 After my last sync my iTunes no longer plays any music not purchased in iTunes. Any suggestions?

    I did the latest update and synched my iPhone 5C, after the sync all music that was not purchased through iTunes will not play on my phone. I figured out how to "homeshare" those songs but they aren't really on my phone so once wifi is off I no longer have them. Any suggestions? Most of these song were off of cds. I don't want to purchase them all again through iTunes what a waste of money. I'm feeling super annoyed.
    Thanks for any help!

    Hi there dryval76!
    There are a couple of reasons for seeing an issue such as that. I have a couple of articles that can help you troubleshoot and find out the source of the issue. The first is an article about troubleshooting issues with playing songs in iTunes, and it can be found here:
    iTunes 11 for Mac: If you have trouble playing music or other audio
    http://support.apple.com/kb/PH12135
    If the issue is happening in all areas of your computer, not just iTunes, then you will want to reference this article:
    Troubleshooting issues with no audio from built-in speakers on Macs
    http://support.apple.com/kb/ts1574
    Thanks for using the Apple Support Communities. Have a good one!
    -Braden

  • When I send a pdf from my pc to ipad the pdf is already open when I scroll down the message so I am unable to save to the ibooks, any suggestions

    When I send a pdf as an attachment from my windows pc to the ipad via outlook mail there are occasions when the pdf is open on the email and not as an attachment which means I cannot store this on ibooks, any suggestions.

    If the document is already open then, if you touch and hold in the body of the document, you will be given a set of options. One of these is to "Open in iBooks".

  • HT1751 My iTunes won't drag to my external hard drive...any suggestions?

    When I attempt to drag my iTunes library to my external hard drive, it will not transfer the folder.  I am using a Mac osx and a free agent external hard drive.  Any suggestions?

    See this migrate iTunes library post. Depending on the layout of the library you may simply need to copy the entire iTunes folder using Windows Explorer without ever firing up iTunes.
    tt2

  • Hello All... Back after a brief absence, things look a little bit different. I'm trying to take a 16 minute mini dv video and compress it for use on the web. I'm interested in any suggestions you may have on settings for the video and audio tracks. I'v

    Hello All...
    Back after a brief absence, things look a little bit different.
    I'm trying to take a 16 minute mini dv video and compress it for use on the web. I'm interested in any suggestions you may have on settings for the video and audio tracks. I've tried using Sorenson 3 (15 frames, key frames set to automatic, 320 x 240) for video and IMA 4:1 (mono) for audio. The resulting video looked great but the file size came in at about 255 Mb.
    Thanks!
    PowerMac G5 1.8 Dual   Mac OS X (10.4.3)  
    Message was edited by: Dan Foley

    Thank you for the replies.  Everyone was correct about the jack, interface, and phasing problems.  I have been unplugging my motu audio interface and then using headphones at work.  I have not changed any detailed audio output settings in logic.  When I read that the jack might be a problem I tried switching headphones.  This actually helped.  I am using dre-beats headphones and they seem to be having issues with the mac/jack-(the phasing/panning problems.  I can use these headphones with other devices but not the mac.  I have to use ipod ear buds and the phasing seems fixed.  Hopefully this information is helpful to someone else. 
    If anyone knows how to correct this issue please let me know its difficult to know what my final mixes are going to sound like and I have had to keep bouncing everything into i-tunes- sync to ipod and then listen in my car radio. 

  • As icloud when I got my iphone.I recently got an iphone. Ever since I have downloaded my iphone pictures to my photo gallery on my PC, my computer crashes when i'm in photo gallery. Any suggestions? I also downloaded itunes as well

    I recently got an iphone5. Ever since I have downloaded my iphone pictures to my photo gallery on my PC, my computer crashes when i'm in photo gallery. Any suggestions? I also downloaded itunes as well as icloud when I got my iphone5.

    No, your iPhone and your iPad should not appear in the finder.
    I'm not sure what you mean about downloading photos with iPhoto being double handling, but you can download direct to a folder with Image Capture. Image Capture can also be used to delete photos from the Camera Roll on the iPhone or iPad (preferrably after they are downloaded).
    You can remove the photos you synced from your phone with iTunes by syncing again with an empty folder, That will delete all the photos that were previously synced that way, replacing them with the contents of the empty folder (that is, nothing). This will not effect photos takes with the camera on your iPhone.

  • I am unable to access iCloud because my iPhone states that my Apple ID and\or password is incorrect.  Based on Apple's own policy my current ID and P/W should be fine to access iCloud.  Any suggestions?

    I am unable to access iCloud because my iPhone states that my Apple ID and\or password is incorrect.  Based on Apple's own policy my current ID and P/W should be fine to access iCloud.  Any suggestions?

    You will have to contact Apple Care and ask for account security for help. Apple ID: Contacting Apple for help with Apple ID account security

Maybe you are looking for

  • XML Publisher Email through Bursting Control File 11i EBS HRMS

    Hi there Is there any body tells me about the security of the XML Publisher Bursting? I have to email hrms pdf data from XML Bursting, Is it secure? Is there any document I can read about the security? Asim Thanks

  • Access applescript in illustrator CS2 plugin

    Does anyone have an update to the ASScripting.h file that allows for the execution of applescript with Illustrator CS2. Can compile plugin but get runtime errors on applescript. My ASScripting.h is from Illustrator 10 is there a new and improved vers

  • Encyrption/Decryption on PDF Files

    Hi, I have to design an application which will encrypt a pdf document and then it archives those document and when i need it should be extracted and then decrypted the file and shown to the user. I am able to encrypt the pdf document but it is not pr

  • Download movie from itunes- get error message -42110; unable to play

    I downloaded a rental movie from iTunes, but when I tried to play it, it would not play, and said there was an error -42110. Any suggestions?

  • Can I install OS 9 on new iMac w/Tiger?

    I just got a new iMac with Tiger installed to replace my old G4. I would like to continue to use some Classic-run software on the new iMac. Do I need to install OS 9? Can I?