Keeping track of Copies + Comparisons in bubbleSort()

Hi,
Having a bit of trouble, I believe my comparisons is working correctly, however my copies is not, I beleive my placement is incorrect, can someone please show me the minor adjustment neccessary?
     public void bubbleSort() {
          int out, in;
          int comp = 0;
          int copies = 0;
          for (out = nElems - 1; out > 1; out--)
               // outer loop (backward)
               for (in = 0; in < out; in++)
                    // inner loop (forward)
                    if (theArray[in] > theArray[in + 1]) // out of order?
                         comp++;
          swap(in, in + 1); // swap them
          copies += 3;
          System.out
          .println("The number of comparisions made using bubble sort: "
                    + comp);
          System.out
          .println("The number copies made using bubble sort:" + copies);
     } // end bubbleSort()

still not working
       public void bubbleSort() {
          int out, in;
          int comp = 0;
          int copies = 0;
          for (out = nElems - 1; out > 1; out--) // outer loop (backward)
               for (in = 0; in < out; in++) // inner loop (forward)
                    if (theArray[in] > theArray[in + 1]) // out of order?
                         swap(in, in + 1); // swap them
                         copies+=3;
               }// end second
               comp++;
          }// end first for
          System.out
          .println("The number of comparisions made using insertion sort: "
                    + comp);
          System.out
          .println("The number copies made using insertion sort:" + copies);
     } // end bubbleSort()

Similar Messages

  • CS5 keeping track of time spent with a project

    I am not sure, if this would qualify as a feature request, or if there is a feture i have just not found yet.
    Also i am not sure, if this is or is not a technical question.
    Often i would like to know, how many hours i have already spent with one project. So is there any possibility in Premiere / and or After Effects, to see that sort of stats?
    Maybe i should find the consistency to keep a book, a pen and a watch on my desk, but i find that hard at times...

    Yeah, Bill that sounds interesting, a third party tool that keeps track, when a file (in this case pproj) is open / being used.
    (so much for on topic...)
    Rod:
    Too bad, megaplayground has no homepage up (but who am i to judge, i am not a webdesigner, so it takes me quite a while to get my portfolio reworked and by the time it is finally finished, i don't like it anymore, then i start again and the dog bites it's own tail.)
    I am sorry, but i'm not sure, what exactly you want to know from me there.
    I suppose, you ask about stuff that interests you...
    Are they working on AVID, FCP, Pr, Media100 ?
    I am quite familiar with AVID in larger companies, have only very basic knowledge of FCP, learned the job on Media100, but that was a couple of years ago and i would say my experiences with Pr are somewhere in the middle.
    So i don't feel like i could tell you any smart questions to ask...
    Make sure to ask them, if they need someone for editing and Motion Graphics, i would love a trip to nyc for a few months
    If you're just getting into this stuff, why don't you just enjoy the tour, chat up the hot girl at the front desk (don't know why, but they always seem to be singles) and check out the coffe?
    and there are no dumb questions within or beyond the basics, dumb questions don't exist, the term "dumb question" is only used by people that are not willing or unable to help but at the same time want to make sure, they're seen as a smarter guy than the inquirer...
    So happy that's something that is not happening inside this forum as far as i have experienced... there are others, and that's also why i am here.
    (was all of that english? it's way past beer fourtyfive and i'm not a native speaker)
    aaanyway, have a fun tour and if they run avid, ask them, why their unity writes much bigger files and needs huge raids in comparison to single workstation setups
    i think, i am overdoing it a bit with the winking smileys, i hate them and am thinking of a splatter movie involving some guys with faces like these...
    What was the OPs topic again? [no, i will not use this smileyfunction now! i am strong, i can resist this childish urge! they will not have my soul! damn.]

  • Do you need to use an email as an apple ID?    We have a family email which is currently the apple ID so I can keep track of purchases but i have 2 iPhones and 2 itouches. Can all 4 devices have different apple ID under the same email address. Also for th

    Do you need to use an email as an apple ID?    We have a family email which is currently the apple ID so I can keep track of purchases but i have 2 iPhones and 2 itouches. Can all 4 devices have different apple ID under the same email address. Also I wanted to know because for the game center we wanted to keep track of each individual not just o e account.  DID I MAKE SENSE

    Figured it out. Thanks.

  • I have an ipad and iphone with a pc laptop at home. I have a program called "Passkeepers on the laptop that keeps track of all my passwords. Can I tranasfer this file to  my ipad or iphone. If yes, how if now what program for ipad or iphone do I need?

    I have an ipad2 and an iphone 3. I also have a PC laptop. The lap top has a program to keep track of my passwords, "Passkeeper" Can I sync with my ipad or iphone? If yes how? If no what app will work on the ipad or phone to keep track of passwords?
    Thanks

    Oh nice, there's a PassKeeper application for the iPhone and iPad.  Simply install it and it should talk you through steps, otherwise their website is probably a great place to check.
    http://itunes.apple.com/us/app/passkeeper/id405021740?mt=8
    I really like the application 1Password, and it works across all the products, Mac, PC, iPad, iPhone.

  • Looking for an application to keep track of things

    Again, forgive me, for I am new to the BB world.
    I have a Palm Zire that I use to keep track of, among other things, all the books I've read - nothing worse that buying a book for the second or third time!  I use the Palm desktop contacts list, filter by "Books", the by author keep track of the titles in the note field.
    Can anyone recommend a BB application to keep track of this for me.  One of the reasons I got this phone was so I wouldn't to carry my PDA and phone with me when shopping.
    Thanks a million
    kznailz

    Hi there!
    For me, I use contact items...I have a whole batch of them that start with "Note" and contain tons of things. One is my weekly shopping list. Another is a list of gift ideas for folks. And many many other things. I like using Contacts as I can not only search them, but they replicate to my desktop PIM (for me, via BES/Exchange) and I can even edit them in my PIM and they wind up on my BB. Handy, IMHO!
    Hope that helps!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • How do I keep track of how many times a method is called inside anthr clas?

    I am writing code for a program that solves a Knight's Tour. A Knight's Tour is a path a Knight Chess piece can take around the board starting at any spot, touching every square once, and only once. I have to write 2 classes and one is provided. The provided class is encrypted and written by our professor. All I know that it does is simulates the game using the two classes I write and provides a print out and prompts to ask the user which square they want to move to next.
    The square class I have to write consists of a constructor that makes a square object that keeps track of its color (white/black) and its status (whether it has been visited, is occupied by the knight, or is free and has not be visited).
    The GameBoard class I have to write is what I am having problems with. I am writing a method that determines how many squares have been visited. The previous mentioned class that my professor wrote for me contains a method moveKnight();. The way the program works is that every time moveKnight() is called a square's status is changed to occupied and therefore visited later. moveKnight() will only work if the move requested by the user is a valid move.
    SO! My main problem (sorry for all the explaining, just trying to give you all the information) is that I don't know how to keep track of how many times moveKnight() is called by the program. If i can figure this out it should be simple. I'm new to java but i believe...
    if(moveKnight() is called)
    {count++;} //count is a member variable already initialized
    return count;
    the moveKnight() is called section within the if() statement is what I am unclear how to do. Please help.
    Thanks, Veritas

    in your case you want 'count' to be a class attribute rather than a local variable. But yes, incrementing it each time that the method is called will serve your purpose.

  • How to keep track of how many times a link has been clicked?

    How to keep track of how many times a link has been clicked or accessed? Do I need to use database for this?

    Hi
    Proably something like this can work,
    1> Have a servlet/bean invoked when the link is linked
    2> have a static variable in that servlet/bean wich gets incremented before the control is passed to another desired page..
    The problem with this approach is that care has to be taken that the servlet/bean is not re-instalised, in case of which the static variable will also be instalised and the data would be lost.
    The best thing is to store the count in the database.
    Regards
    Arathi.

  • My iTunes doesn't keep track of my listening history anymore. It doesn't update play counts and default "Recently Played" playlist.

    My iTunes doesn't keep track of my listening history anymore. It doesn't update play counts and default "Recently Played" playlist. But it still tracking plays from my iPhone and syncing them.
    I've tried to repair it with setup file. Nothing's changed.
    Can you help me with that?
    NOTE: Now I tried disabling the crossfade feature and it worked, started to count again. But I like crossfade, I don't want to keep it off.

    I think I got this figured out. The playcount does update, but not how the previous iPod models update their playcount. Instead of immediately updating the playcount right after you finish the song like the older iPod models, iPod Touch keeps the updates in memory. The next time you connect to iTunes it'll sync those playcounts in memory to the actual songs itself, effectively updating the playcount of the songs only after connecting to iTunes. I have set my syncing manually. That's why after connecting to iTunes, my playcounts are updated. BUT it doesn't solve the mystery of my Smart Playlist. Even though in iTunes, the correct songs are listed, in the iPod Touch, it shows the old playlist.
    Don't you just hate that? It was working fine before on non-iPod touch models. Now we have to live with this new bug. I just hope when they release software 2.0 it fixes these bugs and that they *give it for free!* People shouldn't be charged on something they should have gotten as a support!

  • Why do my songs and audio books keep getting erased when I add a new book?  Now some books will not play and the iPod does not keep track of where I was when I pause a book, leave for music and then go back!

    About a month ago I added some new audio books to my iPod Classic and then after disconnecting, I discovered EVERYTHING had been erased. 
    I had to restore through my iTunes but then I could not load my music back on.
    I uninstalled / reinstalled iTunes and completely reformated the iPod drive.
    I successfully got my music and books back on but then added a new book two days ago only to discover everything got erased AGAIN!!!
    Of course, my 1 Year Warranty was up about a week before the first incident.....
    I formatted the iPod again, uninstalled / reinstalled iTunes (it was freezing during sync) and downloaded all my music and books again.
    Now I have several books that will not play (they play on iTunes and they played on the iPod before all these events) and the iPod does not keep track of where I was in a book when I have to stop and go to something else.
    Does anyone know what is going on with this thing???  I have a 5th Gen Video and in all the years I've had it, I've NEVER had problems like this! 
    Does anyone have any ideas on what I can do to get my iPod Classic up and running properly again?
    Thanks.

    When iTunes/iPod sync process failed due to timeout, the iPod, has only the initilaised  filesytem structure at the start of the Sync.
    The timeout failure could be due to
    Bad hardisk - do the iPod disk diagnostic, refer to this excellent post by tt2
    Slow USB port or resource - Dont use any USB hub, disconnect all other USB devices while syncing
    Timeout due to Antivirus or other plugins - disconnect from Internet and stop the Antivirus or monitoribng software if you are syncing.
    Preferably stop doing other things while syncing this ancient device, which the latest iTunes designer, think will soon be extinct.
    Have a nice day!

  • Any table keep track of Sales order and relevant IDOC

    hi all,
    Do we have any table to keep track Sales order and its relevant IDOC in the system?
    A list of sales order# given by user, from the list, we would like to find a faster way to get the corresponding IDOC.
    thanks.

    Hi Reetha,
    EDIDS table would have the IDOC Number & sales order number. Parameter 2 is the field in EDIDS which would have the sales order number.
    I understand that this table would have many records but i dont think any other table would have the above combination. If you get any other table, then pls. do update @ it on this thread.
    Thanks,
    Best regards,
    Prashant

  • I have been using Find my iPhone for over a year to keep track of my 12 year old daughter occasionally.  All of a sudden when I click on the app icon it asks me to log in.  This has not been the case.  It has always remained logged in in the past.  W

    I have been using find my iPhone on my iPhone 4s for the past year.  I will look at it occasionally to keep track of my 12 year old.  All of a sudden I have to log in every time I click on the app.  I have always remained logged in in the past.. I upgraded to IOS 8 today thinking that might fix it.  It has not.

    adkennon wrote:
    And maybe you don't talk to too many people but I've been on many forums on different websites where people have had similar problems and a lot of people in the store were having battery problems where they were draining too fast. What I learned is that all the people who did not download the updates are good. There phone is working the same. The people who have, they're having battery problems
    I have downloaded every update and my battery life is better than any previous iPhone I have ever owned. I see posts from hundreds of people every day, and this is not a commonly reported problem. While there are a few random reports of battery problems, it is no more than I have seen for any other model or any other version of iOS in almost 8 years. Usually problems of rapid battery drain can be traced to bad apps (FaceBook is the worst offender) or corrupt data being synced from iCloud or other sources (gmail, Windows Live, Yahoo, etc).
    The simple test is to restore the phone as New. Do not create any email accounts. Do not install any apps. Do not enable FaceTime or iMessage. Do not enable Twitter or any other social networking app. Use it for a day and check the battery usage. You will find that it is working well.
    And also see this: http://www.overthought.org/blog/2014/the-ultimate-guide-to-solving-ios-battery-d rain. It is the best treatise I have seen on the subject of battery usage.

  • Adding a counter that keeps track of the total number of times a loop has run, even if LabVIEW has been restarted.

    Hi all,
    I am writing a VI for measuring data and inserting it into a database. The measurements are controlled by a loop that runs once every minute. I want to give each measurement a unique id number and store this too in the database.
    To do this, I want to add a counter to this loop so that I can count the number of times the loop has executed in total. This is, even if the VI, LabVIEW or even th PC is restarted, I want the counter to keep track of the number of executions. If say, the loope executes two times and then the VI is stopped and restarted, I want the following number on the counter to be three.
    Does anyone have an idea about how to do this? I am gratefule for any help!
    Clara
    Message Edited by Clara G on 05-11-2010 08:21 AM
    Solved!
    Go to Solution.

    Not allowed to give away code but I can describe one of my "Totalizers" used to keep track of how much stuff has passed through a fliter so we know when to change it.
    THe Total izer is implemented as an Action Engine.
    It has three actions (methods)
    1) Init - Opens an ini file and reads the last values read and cahces these in shift registers. It also inits a timer so we now how long since the last file I/O.
    2) Update - Uses the data passed by the caller to update the totals. It also checks how long since the last save and if more than one minute it writes to the ini file (forced write).
    3) Read - returns the totals for display and evealuating if a an alarm should be triggered to change the filter.
    Note:
    THe pre-LV 8.6 version of the ini file exposed methods to allow writing to the file. The new ini functions do not expose that functionality and require closing the file.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Is there ANY way to keep track of changes or versions in a dynamic form, viewed in Reader

    I need to provide a measure of content control.
    I looked at acrobat.com for help.  There is a rather convoluted method and I don't know if I can get my company to go along with it.
    I have a dynamic form and it has to be dynamic, so I cannot change it to static to give it Comment/Markup ability - out of the question.
    Does anyone know of ANY way to keep track of changes or comments or anything? And if you know, please be as specific as possible.
    Thanks!

    No replies, so I assume that there isn't any way to do this at present. Do people agree that this would be a really useful feature?

  • Where is the file that keeps track of which mail items were open?

    Searching for the file that keeps track of which mail items were open- sometimes it suddenly is shorter, forgets some of the items of mail that was open, in my 'in box' as it were.
    just happened to me- 15 emails I wanted to keep open till I answered them are now lost back in the mail stack
    any idea where i can find that, retrieve from a backup done last week?
    any trick to fixing this problem?
    hope so
    i gotta track down some of those emails, will be a huge chore to do it one by one
    thanks

    any idea where i can find that, retrieve from a backup done last week?
    Good luck with that; it's not likely to happen.
    any trick to fixing this problem?
    You could just reply to the email right away, rather than putting it off until later, whenever "later" happens to be. Or, you could also put your emails that have not yet been replied to in a separate folder, and move them out into your Inbox when you have replied.
    Mulder

  • Does the Ipod nano 4th gen keep track of playcounts?

    I am not talking about how many times you play a song on the computer on itunes. but does the ipod itself keep track how many times you play a song on the ipod? where can i find this information?

    I did that, and it is completely the same. Here is pictures of it
    this right here is my top 25 for my ipod....
    http://img523.imageshack.us/img523/7069/top25onipodqg6.png
    what you see right here is teh same exact playcounts that is seen on my computer's top 25 when no ipod is connected. there are some wierd differences though, for example flashing lights on my ipod is played only like 5 times or something, whereas on the computer its number 3 played with 375 times played. also pepita(the song on the bottom of the list), is on my top 25 on my computer, but i have not played it yet on my ipod, and the ipod's top 25 accurately shows this. so basically the ipod's top 25 accurately tells teh playcounts for flashing lights and pepita, but not for the rest.
    can anyone make any sense of this? how do i find the playcounts for solely my ipod?
    Message was edited by: shugarhol1c
    Message was edited by: shugarhol1c
    Message was edited by: shugarhol1c

Maybe you are looking for

  • Reports Server 6. installation problem on NT

    Hi, I am trying to install Dev2k Reports server on NT4, SP3. I created the Report server service, configured it to start up service as my user account. The starting up of the service fails. In the ORAHOME/Rerpot60/server/*.log file I keep getting the

  • Problem with buttons in background

    Viewing the problem problem: http://www.ucsdkya.com/ > (you can skip the intro via link in top right) > cilck on the moon in upper right . When the new movie has loaded (its on Level 1), the buttons below it (on Level 0) still make their noises. How

  • VO fetches 25 records, when there are 150 in the iterator.

    Hi All, I'm using View Objects as part of my AD form. In the bean associatd with the form, in one fo my methods, I loop through the Iterator associated with this VO. I notice that only 25 records are being fetched, even though the number of rows is c

  • Html help

    I am trying play with the html on iweb. I have run into a problem though, I cant get images from my computer to load onto the site and the url from the pic is correct. Funny thing is that when I click on the page in idisk/web/sites/iweb/my site it co

  • Multiple Queries on the same WB-sheet - overlapping/overwriting

    Hi experts, we need to create a workbook with more than one query on a single workbook-sheet. Unfortunately the cell-range needed by the queries is not static or good predictable. The problem is that if you position 2 analysis-tables below each other