Can someone help me why this quick sort doesn't work

public class QuickSortII {
     static void sort(int a[], int lo0, int hi0) {
        int lo = lo0;
        int hi = hi0;
        if (lo >= hi) {
            return;
        int mid = a[(lo + hi) / 2];
        while (lo < hi) {
            while (lo<hi && a[lo] < mid) {
                lo++;
            while (lo<hi && a[hi] >= mid) {
                hi--;
            if (lo < hi) {
                int T = a[lo];
                a[lo] = a[hi];
                a[hi] = T;
        if (hi < lo) {
            int T = hi;
            hi = lo;
            lo = T;
        sort(a, lo0, lo);
        sort(a, lo == lo0 ? lo+1 : lo, hi0);
    static void sort(int a[]) {
        sort(a, 0, a.length-1);
     static public void main(String[] args) {
          int a[] = new int[20];
          a[0] = 18;
          a[1] = 11;
          a[2] = 12;
          a[3] = 4;
          a[4] = 20;
          a[5] = 5;
          a[6] = 1;
          a[7] = 3;
          a[8] = 16;
          a[9] = 8;
          a[10] = 7;
          a[11] = 17;
          a[12] = 9;
          a[13] = 6;
          a[14] = 19;
          a[15] = 2;
          a[16] = 13;
          a[17] = 15;
          a[18] = 10;
          a[19] = 14;
          sort(a);
          for (int j = 0; j < 20; j++) {
               System.out.print(a[j] + " ");
}it doesn't sort the list

it doesn't sort the list Please explain why you think it should. Doing so will help you understand the code.
~

Similar Messages

  • I have league of legends music running in the background when 1. did not even open the application, and 2. i deleted the application long ago. Can someone help me fix this so it doesn't bug me!!

    For the last two months, when i am working some league of legends music (i think it is) pops up in the background and the only way i can turn it off is by restarting the computer. It is driving me nuts. Why does it do this when i've deleted the application ages ago and how do i fix my computer?

    Please help me people, im a dumb uni student after all!

  • Can someone help explain why my iWeb website doesn't publish correctly...

    I'm a professor and I'm trying to build a professional website--nothing fancy, six or seven pages and perhaps a blog. The site I have built on iWeb looks wonderful in iWeb, but once I publish the site (GoDaddy is hosting it), various text boxes, fonts, and background shapes get randomly distorted. Moreover, the site has different errors when viewed on my iPad, when viewed on my Macbook in Safari, and when viewed on Macbook in Mozilla. From what I've been gathering, web developers don't like iWeb. I'm not a computer expert, so I like the usability of iWeb (I'm not using any of their prefab templates--that might be the problem). I just want the site that I've built in the program (which looks good) to actually publish correctly. Any help would be greatly appreciated, even if it is just pointing to other software...
    Thanks!
    -Will
    Greensboro, NC

    What's the URL of your site so we can examine it first hand?   Also if you're considering some serious blogging I suggest you create your blog on one of the established blogging sites like Posterous, WordPress or Blogger. This will allow you to manage your blog from any computer anywhere and even from some mobile devices.  With an iWeb blog you must have a Mac and the domain.sites2 file used to create the site.
    Then you can embed that blog into one of your iWeb pages as shown on this demo page: Embed a Site Within an iWeb Page
    OT

  • I have FF 3.6.25 and can't install the yoville zynga gamebar i get an error msg that its not a valid install package - 207. can someone help me with this so that it will work?

    i'm running ff 3.6.25 and can't install the yoville zynga gamebar the message i get is as follows:
    Firefox could not install the file at http://zynga.ourtoolbar.com/xpi because: Not a valid install package -207
    i installed it on my mom's pc after installing ff to it and it worked fine.

    Hi,
    You may have to update Firefox. Please also check the Firefox version on mom's PC: '''Help''' ('''Alt''' + '''H''') > '''About Firefox'''.
    https://www.mozilla.org/en-US/firefox/new/
    Useful links:
    [https://support.mozilla.com/en-US/kb/Options%20window All about Tools > Options]
    [http://kb.mozillazine.org/About:config Going beyond Tools > Options - about:config]
    [http://kb.mozillazine.org/About:config_entries about:config Entries]
    [https://support.mozilla.com/en-US/kb/Page%20Info%20window Page Info] Tools (Alt + T) > Page Info, Right-click > View Page Info
    [https://support.mozilla.com/en-US/kb/Keyboard%20shortcuts Keyboard Shortcuts]
    [https://support.mozilla.com/en-US/kb/Viewing%20video%20in%20Firefox%20without%20a%20plugin Viewing Video without Plugins]
    [http://kb.mozillazine.org/Profile_folder_-_Firefox Firefox Profile Folder & Files]
    [https://developer.mozilla.org/en/Command_Line_Options#Browser Firefox Commands]
    [https://support.mozilla.com/en-US/kb/Basic%20Troubleshooting Basic Troubleshooting]
    [https://support.mozilla.com/en-US/kb/common-questions-after-upgrading-firefox-36 After Upgrading]
    [https://support.mozilla.com/en-US/kb/Safe%20Mode Safe Mode]
    [http://kb.mozillazine.org/Problematic_extensions Problematic Extensions]
    [https://support.mozilla.com/en-US/kb/Troubleshooting%20extensions%20and%20themes Troubleshooting Extensions and Themes]
    [https://support.mozilla.com/en-US/kb/Troubleshooting%20plugins Troubleshooting Plugins]
    [http://kb.mozillazine.org/Testing_plugins Testing Plugins]

  • HT5655 I followed all the instructions to update Flash Player, but the installation fails at around 90%, it says that there is an Application running (Safari) bit I actually close all Apps. already. can someone help me with this issue ?? Thanks

    I have followed the instructions to update Flash Player, the Installation Fails at about 90%, it says that there is an Application running (Safari) and it says to close all the apps. and start again ... but I already close all the Applications ... none is running ... can someone help me with this issue ??? Thanks ...

    Dear Dominic
    Brilliant reply. Simple English. Simple to follow instructions. And it worked immediately, first time.
    Why couldn't the Apple and Adobe corporations get their programming right first time? We spend billions of UK pounds and US dollars with them. They reply with incompetent programming such as this, and arrogance to their customers in issuing faulty systems without doing the most rudimentary checks.
    Anyway, I certainly shan't be buying another Apple as this is the most unreliable, most incomprehensible, most illogical and downright thoughtless shoddy piece of computer kit which I have ever owned. And all of it is rubbish ~ emails disappear, photos can't be organised properly, spreadsheets don't work, Pages is laborious… the list goes on and on...
    But thanks to you Dominic, I have been able to load Adoble Flashj… maybe eyou should get  a job at Apple, and set them all on the right course to how to work simply and correctly with customers.
    Thanks again,
    David

  • Some of my photos in iphoto turn blank (white) when I tried to edit the size like zoon in and out.Can someone help me on this?

    Some of my photos in Iphoto turn blank (white) when I tried to edit the size like zoon in and out.Can someone help me on this?

    As a Test:
    Hold down the option (or alt) key and launch iPhoto. From the resulting menu select 'Create Library'
    Import a few pics into this new, blank library. Is the Problem repeated there?

  • So i have an apple ipod touch 1st generation and it is not charging! It shows the charging sign but its taking a really long time to charge. Ive had it charging for at least 3 hours and it still says under 20% so can someone help me figure this out??

    So i have an apple ipod touch 1st generation and it is not charging! It shows the charging sign but its taking a really long time to charge. Ive had it charging for at least 3 hours and it still says under 20% so can someone help me figure this out??

    Not Charge
    - See:      
    iPod touch: Hardware troubleshooting
    iPhone and iPod touch: Charging the battery
    - Try another cable.
    - Try another charging source
    - Inspect the dock connector on the iPod for bent or missing contacts, foreign material, corroded contacts, broken, missing or cracked plastic.
    - Make an appointment at the Genius Bar of an Apple store.
      Apple Retail Store - Genius Bar 

  • I have iOS 7. When I go to the itunes store on my ipod touch it gives me a blank screen with nothing on it. I restarted my ipod touch and it didn't work. Can someone help me with this?

    I have iOS 7. When I go to the itunes store on my ipod touch it gives me a blank screen with nothing on it. I restarted my ipod touch and it didn't work. Can someone help me with this?

    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Go to Settings>iTunes and App stores and sign out and sign back in
    - Reset all settings      
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up                                                                
    - Restore to factory settings/new iOS device.      

  • The calender on my iPhone 4 with iOS 6 no longer syncs with iCal 4.0.4 on my mac OS 10.6.8. However it is syncing with my iCloud account. Can someone help me with this?

    The calender on my iPhone 4 with iOS 6 no longer syncs with iCal 4.0.4 on my mac OS 10.6.8. However it is syncing with my iCloud account. Can someone help me with this?

    FYI: It seems it was a network problem with my WinXP PC. After complete deletion and new installation of XP and iTunes my iPhone will be recognized correctly, Wifi synchronization works (mostly) fine.

  • I'm trying to clean up my mailbox and when I delete an item(s) I get a message that say's "operation could not be completed- file exists. Further, when I do this one message is copied (not deleted) to the trash folder. Can someone help me through this?

    I'm trying to clean my mailbox and when I click on delete or highlight and move to trash I get a message that says "operation could not be completed - file exists. Further, when I select a message or group of messages, one of them is copied (not deleted) to the trash folder. Can someone help me through this?
    Thanks.

    It's a POP account. I decided to clean up my mailbox today after noticing the computer was real slow after USA Today started sending their daily top stories with new graphics. Also before I noticed the problem with mail deletion - two things happened. 1) I updated security sofware as prompted by Apple and 2) downloaded Mackeeper and went throught some preliminary scans but did not buy their package. Thanks forn nstaying with me.

  • I'm having issues loading Youtube on my MacBook Pro for about a week now.  I'm not sure if this is because of my computer or internet but my sister's PC loads Youtube completely fine.  Can someone help me figure this out?

    I'm having issues loading Youtube on my MacBook Pro for about a week now.  I'm not sure if this is because of my computer or internet but my sister's PC loads Youtube completely fine.  Can someone help me figure this out?

    Hi, I had been having the same problem for over a week, but both my window's HP and my 2011 macbook pro barely could load youtube.  What kind of router you have?  I was using a belkin play router that was only 8 months old, switched to a new AirPort Extreme Base Station and now everything works perfect.

  • Most of the time I get The Connection Was Reset. Can someone tell me why this happens?

    When I click on Firefox or when browsing or going from one site to the other I get "The connection was reset" then have to click on Try Again.
    Can someone tell me why this is happening?
    Thank you.
    THE CONNECTION WAS RESET again this morning. I even get this message when I click on the Firefox Icon to get on the net. When for example I download something then it returns me to their site I get The Connection Was Reset. When I uninstall a program and it sends to to their site in order to answer as to why I am uninstalling their program then I get The Connection Was Reset.
    Every time this happens I have to click on Try Again and find this to be annoying.
    This does not happen once or twice a week, it happen ALL THE TIME.
    This morning I went to Safe Mode and followed the instructions on INTERRUPTED OR RESET CONNECTION which tells us what to do but this did not work either.
    Would be great if someone was able to let me know what to do in order to prevent this message appearing all the time.

    Do not know how to delete this reply. I replied instead of editing my question. I have edited the above now.

  • TS1292 i have a spanish gift card that won't work with my canadian account. can someone help me solve this

    i found an old gift card that i got with my ipod from spain
    i have a canadian account. when i tried using the gift card it said i couldn't use the spanish gift card with my canadian account. can someone help me solve this problem
    the gift card is 15 euros

    Sorry, but you cannot use that card with a Canadian iTunes Store account. A gift card is valid only in the country of purchase. You'll need to give or sell that card to someone in Spain.
    Regards.

  • I have a problem with my blackberry 9360, I bought it last 2months, and now when I use video camera or camera I saw a red and blue line. Can someone help me with this issue?

    I have a problem with my blackberry 9360, I bought it last 2months, and now when I use video camera or camera I saw a red and blue line. Can someone help me with this issue?

    Hello zukafu, 
    Welcome to the forums. 
    In this case we can try to reload the software on the BlackBerry® smartphone to make sure it is running the latest version and there are no issues with the OS.
    Here is how to backup your BlackBerry smartphone http://bbry.lv/oPVWXc
    Once you have backed up your BlackBerry smartphone please follow the link below to complete a clean reload of the BlackBerry smartphone software.
    Link: http://www.blackberry.com/btsc/KB03621
    Once completed test it and proceed with a selective restore, here is how to restore http://bbry.lv/qgQxLo
    Thank you
    -SR
    Come follow your BlackBerry Technical Team on twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.Click Solution? for posts that have solved your issue(s)!

  • HT4203 I have turned off the Data use on the I-phone 4s but am told by AT&T that data is still being used for applications.  How is this possible. Can someone help me understand this.  Thanks.

    I have turned off the Data use on the I-phone 4s but am told by AT&T that data is still being used for applications.  How is this possible. Can someone help me understand this. 

    I assume you are including the STIX font as part of your epub files?     
    Perhaps the folks who do this blog might be able to help -- they have done some work with font embedding:
    http://www.pigsgourdsandwikis.com/2011/04/embedding-fonts-in-epub-ipad-iphone-an d.html

Maybe you are looking for

  • Is it possible to create a form text field that needs to be filled out in Korean

    I have created a flyer for a client in InDesign. It's in Korean. The font I use is Apple SD Gothic. But when I create pdf with form fields from it I can't select that font for the field attribute. Is there a way to embed the font in the pdf for the f

  • Camera Nokia lumia 710

    5MP stills 720 video but does it have secondary camera? Solved! Go to Solution.

  • How to use encryption?

    Hi all, After installing Oracle db 11.2.0.1 on my Win7 laptop, I got the following completion message: The Database Control URL is https://localhost:5500/em Management Repository has been placed in secure mode wherein Enterprise Manager data will be

  • Report Builder 3.0 Category Listing

    .  I have a budget report assembled with user drop-down parameters of "Budget Year", "Budget Department", and "Departmental Category". The report runs just fine with a single selected "Departmental Category" but if I select multiple "Departmental Cat

  • Converting PR to Schedule Line

    Dear all:         How can I converting PRs which assigned source with Outline Agreement to Schedule Lines? I can convert just one PR to Schedule Line in MD04, but I hav no ideal about a lot PRs converting in the same time like converting PRs to POs w