Desperate help needed with insertion sort code

Here is my insertion sort code for a doubly linked list that does not work. I cannot figure out why and I've been trying everything for the last 10 hours! Please Please help..
public void insertionSort()
    Node pointer=head;
    while(pointer.next!=null)
        Node insert=pointer.next;
        if (insert.item.compareTo(pointer.item)>0)
            pointer=pointer.next;
        else
            insert.prev.next=insert.next;
            insert.next.prev=insert.prev;
            if (head.item.compareTo(insert.item)>0)
                insert.next=head;
                insert.prev=null;
                head.prev=insert;
                head=insert;
            Node current =head.next;
            while (current.item.compareTo(insert.item)<0)
                current=current.next;
            insert.next=current;
            insert.prev=current.prev;
            current.prev.next=insert;
            current.prev=insert;
}

It makes sense tracing it out on paper, running it,
the program never ends.This means that there is an infinite loop somewhere in your code. Find the loops and put some System.out.println()'s in them to see where it's going wrong.

Similar Messages

  • Pros help needed with post data code

    i needed to change the code below to post the userAnswer from radio button group,  to an ASPX page so i can read the data in and post it to a database. can anyone help. thanks
    btnCheck.addEventListener(MouseEvent.CLICK, checkAnswer);
    function checkAnswer(evt:MouseEvent):void {
    userAnswer = String(rbg.selectedData);
        messageBox.text =  userAnswer + " has been clicked";

    //Create the loader object
    var prodloader:URLLoader = new URLLoader ();
    //Create a URLVariables object to store the details
    var variables: URLVariables = new URLVariables();
    //Createthe URLRequest object to specify the file to be loaded and the method ie post
    var url:String = "url here";
    var prodreq:URLRequest = new URLRequest (url);
    prodreq.method = URLRequestMethod.POST;
    prodreq.data = variables;
    function submitHandler(event:Event):void {
        variables.productId = whatever;
        prodloader.load(prodreq);
        btnSubmit.addEventListener(MouseEvent.CLICK, submitHandler);
        function contentLoaded(event:Event):void {
           //Stuff here
            prodloader.addEventListener(Event.COMPLETE, contentLoaded);

  • Desperate help need with Document Listener

    I'm working on a very cool freeware Java text editor, that is working beautifully, except for the code used to change the color of reserved words, etc, on the fly...
    At the moment, I use a documentlistener. When text is inserted, I need to color some of that text automatically. However, when I try to call setCharacterAttributes in DefaultStyledDocument, it causes a runtime exception, Illegal State Exception (Attempt to mutate in notification)>
    I understand how this exception is caused, but how do I get around it?

    Thanks for the replies. They were very helpful, and I have now managed to sort the problem, although in a different way that involves using the key listening class you can add to containers...
    The java editor is called j-Scribe, and is a text editor dedicated to java. I've designed it to be more user friendly than other text editors, with a useful interface. The code dispplay is all highlighted, and clicking on a brace collapses that section of code, to make larger classes easier to work through... There are also some nifty filemanagement windows, including a history pane similar to IE6, and one click access to all open files, and one click access to all of their save and close functions... There are wizards to automate creation of certain elements of code, and eventually a number of intelligent features will be added. The program makes extensive use of xml to store all of the information generated by the program.
    I'm working on the alpha version right now, for release in about two weeks. The beta will be out three - four weeks after that, and the release should be late September / early October time...
    If you're interested, e-mail me and I'll add you to the list for the alpha and beta test releases...
    [email protected]

  • Help needed with part of code

    Hi all,
    Need some advice on how to write part of this code to print cost and retail!SEE ASTERISKS**
    I know its smoething to with this part of code:-
    System.out.println("Part No." +"\t"+ "Quantity." +"\t"+ "Cost Price." +"\t"+ "Retail Price.");
    System.out.println(input_part +"\t"+ "\t" + qty[input_part-1] + "\n");
    Just dont know how to add the cost and retail to printout!!
    Any help appreciated
    Paul
    import java.io.*;
    import B102.*;
    public class ass2{
    public static void main(String[] args) throws IOException{
    char more='y';
    while(more=='y'){
    int i;
    int numrecords = 0; int size = 0;
    int quantity = 0;int input_part = 0;
    String line;
    String filename;
    int qty[];     
    int partno[];
    double cost[];
    double retail[];
    // Get the name of the input file
    System.out.print("Enter the name of the input file: ");
    filename = Keybd.in.readLine();
    // Open the file for reading
    BufferedReader in = new BufferedReader(new FileReader(filename));
    // read the first line of the file to determine the size of the array
    line = in.readLine();
    numrecords = Integer.parseInt(line.trim());
    // create the qty array with the inputed size
    qty = new int[numrecords];
    partno = new int[numrecords];
    cost = new double[numrecords];
    retail = new double[numrecords];
    /* Read part numbers */
    for(i = 0; i < numrecords; i++){
    line = in.readLine();
    partno[i] = Integer.parseInt(line.trim());
    /* Read cost price */
    for(i = 0; i < numrecords; i++) {
    line = in.readLine();
    cost[i] = Double.parseDouble(line.trim());
    /* Read retail price */
    for(i = 0; i < numrecords; i++){
    line = in.readLine();
    retail[i] = Double.parseDouble(line.trim());
    /* Read quantity */
    for(i = 0; i < numrecords; i++){
    line = in.readLine();
    qty[i] = Integer.parseInt(line.trim());
    // close the file
    try{
    in.close();
    }catch (IOException iox){
    System.out.println("problem closing input file");
    // the file is now closed
    System.out.print("Enter part number: ");
    input_part = Keybd.in.readInt();
    // get a quantity
    System.out.print("Enter quantity: ");
    quantity = Keybd.in.readInt();
    // test if there is sufficient stock, if not print message
    if(quantity > qty[input_part-1])
    System.out.println("Not enough stock!");
    else
    System.out.println("Stock level: "+qty[input_part-1]);
    //output contents of arrays
    for(i=0;i<numrecords;i++){
    System.out.print(partno[i]+"\t");
    System.out.print(cost[i]+"\t");
    System.out.print(retail[i]+"\t");
    System.out.print(qty[i]+"\t");
    System.out.println();
    // output
    System.out.println("You entered part number: "+input_part);
    System.out.println("You entered quantity: "+quantity);
    System.out.println("Part No." +"\t"+ "Quantity." +"\t"+ "Cost Price." +"\t"+ "Retail Price.");
    System.out.println(input_part +"\t"+ "\t" + qty[input_part-1] + "\n");
    System.out.println("Do you wish to make another purchase? (y) for yes or any other key to quit.");
    more=Keybd.in.readChar();

    2 things:
    1. Always surround your code with [ code] [ /code] blocks (without the spaces) - otherwise no one can read what you are doing.
    2. Will the following work for you? From your description it is pretty much impossible to tell what you are actually having problems with...
    System.out.println("Part No." +"\t"+ "Quantity." +"\t"+ "Cost Price." +"\t"+ "Retail Price.");
    System.out.println(input_part +"\t"+ "\t" + qty[input_part-1] + "\t" + cost[input_part-1] + "\t" + retail[input_part-1] + "\n");

  • Desperate help needed with writing files

    I need to know how i can write files with an applet to a directory so that i can retrieve the files for later use. I need to know how to do this step by step as i am a beginner. i've tried looking for tutorials and i just can't seem to get it working.
    can somebody PLEASE provide me with some valid info here as i'm sure that many others have exactly the same problem and can refer to this topic.
    much appreciated.
    thnx

    You will need a certificate to sign the Applet with.
    here is a rehash of the script I use to to this...
    CERTIFICATE_FILE_NAME is the name of your certificate file.
    c:\windows\.keystorefile is the path & name of your keystore
    jar cf  tmp.jar *.class *.gif *.jpg *.au
    jarsigner -keystore c:\windows\.keystorefile -signedjar YOUR_DESTJARNAME.jar tmp.jar  CERTIFICATE_FILE_NAME
    del tmp.jar
    del *.classThis is excatly what you need to do and your file writes will work.
    Now you may need to tweak your getImage to find the files within the
    jar but thats another story.
    (T)

  • Desperate Help needed with the 4Hi 8x16x48x

    Hi all,
    that my first post. I was wondering if any of you guys could help.I've got a 48*16*48*. I've used it for a couple of times but now it doesn't seem to work, it takes ages to read and sometimes it doesn't detect the Cd.Is something wrong with the writer itself or the nero software?can anyone of you help? ?(  ?(  ;(
    thanks
    kaz

    The CDRW is faulty. Try to claim warranty if the drive is new.

  • Help needed with iPad pass code

    Just bought a new iPad and backed up from my old one.
    Now being asked for a pass code but its not accepting the code from my previous iPad
    Can anyone help?

    If you can't remember the pass code you will have to wipe and restore as new.
    http://support.apple.com/kb/ht1212

  • Desperate help needed with quote create issues ...

    Dear SD experts
    I am trying to create a quote using 'BAPI_QUOTATION_CREATEFROMDATA2' in the test mode.
    I am entering the bear minimum required (without opening any parameters other than the default
    which are QUOTATION_HEADER_IN and QUOTATION_PARTNERS.
    The problem that I am seeing is with QUOTATION_PARTNERS-ITM_NUMBER.
    When I give QUOTATION_PARTNERS-ITM_NUMBER = '0000000' and run, I get a bogus
    message that the quote (with a number assigned) is created. But when I try to open using VA23
    it is not and even the table 'VBAK' doesn't have an entry for this.
    However when I change QUOTATION_PARTNERS-ITM_NUMBER = '0000020'  where 000020 is a valid value, I get a message that says  "112 Please enter sold-to party or ship-to party".
    What I don't understand is how this ITM_NUMBER "item number of SD document"  is connected
    to ship-to variable. How can I make sure that these two have proper relationship in the database.
    Any suggestions or comments will be highly appreciated.
    Thanks
    Ram

    not answered but am closing this to make place for other questions.

  • Hi folks, can someone help me with my redemption code? have a creative cloud id made last week. but in order to install my products I have a redemption code needed but that I can't find anywhere. can someone help me??? Thank you

    Hi folks, can someone help me with my redemption code?
    have a creative cloud id made last week.
    but in order to install my products I have a redemption code needed but that I can't find anywhere. can someone help me???
    Thank you

    I have a fully companies annual subscription of 69.99 a month.
    but I can only download the 30-day trial versions.
    and if I want to put on them completely firedamp should I enter a redemption code. could it be that the code later emailed word?
    Met vriendelijke groet,
    Dave Dros
    Van: "hans-g." <[email protected]<mailto:[email protected]>>
    Beantwoorden - Aan: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
    Datum: dinsdag 21 oktober 2014 10:03
    Aan: iMac <[email protected]<mailto:[email protected]>>
    Onderwerp:  Hi folks, can someone help me with my redemption code? have a creative cloud id made last week. but in order to install my products I have a redemption code needed but that I can't find anywhere. can someone help me??? Thank you
    Hi folks, can someone help me with my redemption code? have a creative cloud id made last week. but in order to install my products I have a redemption code needed but that I can't find anywhere. can someone help me??? Thank you
    created by hans-g.<https://forums.adobe.com/people/hans-g.> in Adobe Creative Cloud - View the full discussion<https://forums.adobe.com/message/6850359#6850359>

  • HELP NEEDED WITH ADDAPTER-DVI TO VGA.

    PLEASE ...HELP NEEDED WITH WIRING CROSS OVER....CAN YOU HELP WITH BACK OF PLUG CONNECTIONS...I SORTA UNDERSTAND THE PINOUTS BUT CANT MAKE AN EXACT MACH...WOULD LIKE TO BE 100% SURE...
    ......THIS ENSURES NO SMOKE!!!                                                                                           
    THE CARD IS AN ATI RADEON RX9250-DUAL HEAD-.........ADDAPTER IS DVI(ANALOG)MALE TO VGA(ANALOG)FEMALE.
    ANY HELP VERY MUCH APPRECIATED........ SEEMS YOU NEED TO BE ROCKET SCI TO ATTACH A BLOODY PICTURE...SO THIS HAS BEEN BIG WASTE OF FING TIME!

    Quote from: BOBHIGH on 17-December-05, 09:21:31
    Get over it mate !
    I find it easy t read CAPS...and if you dont like it ...DONT READ IT!
    And why bother to reply...some people have nothing better to do.
    Yes there chep and easy to come by...Ive already got a new one.
    All I wanted was to make a diagram of whats inside the bloody thing...it was a simple question and required a simple answer.
    NO NEED TO A WANKA !!
    I feel a bann comming up.
    Have you tryed Google ? really.. your question is inrelevant. No need to reply indeed.
    Why do you come here asking this question anyway ? is it becouse you have a MSI gfx card ? and the adapter has nothing to do with this ?
    You think you can come in here yelling.. thinking we have to put up with it and accept your style of posting. This is not a MSI tech center.. it's a user to user center.. Your question has nothing to do with MSI relavant things anyway's.
    Google = your friend.
    Quote from: BOBHIGH on 17-December-05, 09:21:31
    it was a simple question and required a simple answer
    Simple for who ? you (buying a new one) ? me ? we ?   .really...........
    Quote from: Dynamike on 16-December-05, 04:11:48
    1: There are allot of diffrent types of those adapters.
    If any of the mods have a problem about my reply.. please pm me.

  • Urgent help needed with un-removable junk mail that froze Mail!!

    Urgent help needed with un-removable junk mail that froze Mail?
    I had 7 junk mails come in this morning, 5 went straight to junk and 2 more I junked.
    When I clicked on the Junk folder to empty it, it froze Mail and I can't click on anything, I had to force quit Mail and re-open it. When it re-opens the Junk folder is selected and it is froze, I can't do anything.
    I repaired permissions, it did nothing.
    I re-booted my computer, on opening Mail the In folder was selected, when I selected Junk, again, it locks up Mail and I can't select them to delete them?
    Anyone know how I can delete these Junk mails from my Junk folder without having to open Mail to do it as it would appear this will be the only solution to the problem.

    Hi Nigel
    If you hold the Shift key when opening the mail app, it will start up without any folders selected & no emails showing. Hopefully this will enable you to start Mail ok.
    Then from the Mail menus - choose Mailbox-Erase Junk Mail . The problem mail should now be in the trash. If there's nothing you want to retain from the Trash, you should now choose Mailbox- Erase Deleted Messages....
    If you need to double-check the Trash for anything you might want to retain, then view the Trash folder first, before using Erase Junk Mail & move anything you wish to keep to another folder.
    The shift key starts Mail in a sort of Safe mode.

  • Help needed with header and upload onto business catalyst

    Can someone help with a problem over a header please?
    I have inserted a rectangle with a jpeg image in  background, in the 'header' section, underneath the menu. It comes up fine on most pages when previsualised, going right to the side of the screen, but stops just before the edge on certain pages. I have double checked that I have placed it in the right place in relation to the guides on the page.
    That's one problem.
    The second problem is that I tried to upload onto business catalyst, which got to 60% and refused to go any further, saying it couldn't find the header picture, giving the title and then u4833-3.fr.png. The picture is in the right folder I have double checked. And it isn't a png. Does it have to be ?
    And the third problem is that I got an email following my upload from business catalyst in Swedish. I am living in France.
    Can anyone help ? Thanks.

    Thanks for replying,
    How can I check the preview in other browsers before I publish a provisional site with BC?
    The rectangle width issue happens on certain pages but not others. The Welecom page is fine when the menu is active, also the contact page, but others are slightly too narrow. Changing the menu spacing doesn’t help - I was already on uniform but tried changing to regular and back.
    In design mode the rectangle is set to the edge of the browser, that’s 100%browser width right?
    Re BC I have about 200 images on 24 different pages and it seems to be having difficulty uploading some of them. But it has managed a couple I named with spaces but not others I named with just one name.
    Is there an issue on size of pictures ? If I need to replace is there a quick way to rename and relink or do I have to insert the photos all over again?
    I’m a novice with Muse with an ambitious site !
    Thanks for your help.
    Mary Featherstone
    Envoyé depuis Courrier Windows
    De : Sanjit_Das
    Envoyé : vendredi 14 février 2014 22:15
    À : MFeatherstone
    Re: Help needed with header and upload onto business catalyst
    created by Sanjit_Das in Help with using Adobe Muse CC - View the full discussion 
    Hi
    Answering the questions :
    - Have you checked the preview in Muse and also in other browsers ?
    - Does the rectangle width issue happens when menu is active , or in any specific state , Try to change the menu with uniform spacing and then check.
    - In design view the rectangle is set to 100% browser width ?
    With publishing :
    - Please try to rename the image file and then relink
    - If it happens with other images as well , see if all the image names includes strange characters or spaces.
    - Try again to publish
    With e-mail from BC :
    - Under preferences , please check the country selected.
    - If you have previously created partner account in BC and selected country and language then it would follow that, please check that.
    Thanks,
    Sanjit
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/6121942#6121942
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/6121942#6121942
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/6121942#6121942. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Help with using Adobe Muse CC at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

  • Help needed with java

    Hello everyone
    I'm a Student and new to java and I have been given a question which I have to go through. I have come across a problem with one of the questions and am stuck, so I was wondering if you guys could help me out.
    here is my code so far:
    A Class that maintains Information about a book
    This might form part of a larger application such
    as a library system, for example.
    @author (your name)
    *@version (a version number or a date)*
    public class Book
    // instance variables or fields
    private String author;
    private String title;
    Set the author and title when the book object is constructed
    public Book(String bookAuthor, String bookTitle)
    author = bookAuthor;
    title = bookTitle;
    Return The name of the author.
    public String getAuthor()
    return author;
    Return The name of the title.
    public String getTitle()
    return title;
    and below are the questions that I need to complete. they just want me to add codes to my current one, but the problem is I don't know where to put them and how I should word them, if that makes sense.
    Add a further instance variable/field pages to the Book class to store the number of pages in the book.
    This should be of type int and should be set to 0 in the Constructor.
    Add a second Constructor with signature
    public Book(String bookAuthor, String bookTitle, int noPages) so it has a third parameter passed to it as well as the author and title;
    this parameter is used - obviously?? - to initialise the number of pages.
    Note: This is easiest done by making a copy of the existing Constructor and adding the parameter.
    Add a getPages() accessor method that returns the number of pages in the book.
    Add a method printDetails() to your Book class. This should print out the Author title and number of pages to the Terminal Window. It is your choice as to how the data is formatted, perhaps all on one line, perhaps on three, and with or without explanatory text. For instance you could print out in the format:
    Title: Robinson Crusoe, Author: Daniel Defoe, Pages:226
    Add a further instance variable/field refNumber() to your Book class. This stores the Library's reference number. It should be of type String and be initialised to the empty String "" in the constructor, as its initial value is not passed in as a parameter. Instead a public mutator method with the signature:
    public void setRefNumber(String ref) should be created. The body of this method should assign the value of the method parameter ref to the refNumber.
    Add a corresponding getRefNumber() accessor method to your class so you can check that the mutator works correctly
    Modify your printDetails() method to include printing the reference number of the book.
    However the method should print the reference number only if it has been set - that is the refNumber has a non-zero length.
    If it has not been set, print "ZZZ" instead.
    Hint Use a conditional statement whose test calls the length() method of the refNumber String and gives a result like:
    Title: Jane Eyre, Author: Charlotte Bronte, Pages:226, RefNo: CB479 or, if the reference number is not set:
    Title: Robinson Crusoe, Author: Daniel Defoe, Pages:347, RefNo: ZZZ
    Modify your setRefNumber() method so that it sets the refNumber field only if the parameter is a string of at least three characters. If it is less than three, then print an error message (which must contain the word error) and leave the field unchanged
    Add a further integer variable/field borrowed to the Book class, to keep a count of the number of times a book has been borrowed. It should (obviously??) be set to 0 in the constructor.
    Add a mutator method borrow() to the class. This should increment (add 1 to) the value of borrowed each time it is called.
    Include an accessor method getBorrowed() that returns the value of borrowed
    Modify Print Details so that it includes the value of the borrowed field along with some explanatory text
    PS. sorry it looks so messey

    1. In the future, please use a more meaningful subject. "Help needed with java" contains no information. The very fact that you're posting here tells us you need help with Java. The point of the subject is to give the forum an idea of what kind of problem you're having, so that individuals can decide if they're interested and qualified to help.
    2. You need to ask a specific question. If you have no idea where to start, then start here: [http://home.earthlink.net/~patricia_shanahan/beginner.html]
    3. When you post code, use code tags. Copy the code from the original source in your editor (NOT from an earlier post here, where it will already have lost all formatting), paste it in here, highlight it, and click the CODE button.

  • Help needed with Vista 64 Ultimate

    "Help needed with Vista 64 UltimateI I need some help in getting XFI Dolby digital to work
    Okay so i went out and I bought a yamaha 630BL reciever, a digital coaxial s/pdif, and a 3.5mm phono plug to fit perfectly to my XFI Extreme Music
    -The audio plays fine and reports as a PCM stream when I play it normally, but I can't get dolby digital or DTS to enable for some reason eventhough I bought the DDL & DTS Connect Pack for $4.72
    When I click dolby digital li've in DDL it jumps back up to off and has this [The operation was unsuccessful. Please try again or reinstall the application].
    Message Edited by Fuzion64 on 03-06-2009 05:33 AMS/PDIF I/O was enabled under speakers in control panel/sound, but S/PDIF Out function was totally disabled
    once I set this to enabled Dolby and DTS went acti've.
    I also have a question on 5. and Vista 64
    -When I game I normally use headphones in game mode or 2. with my headphones, the reason for this is if I set it on 5. I get sounds coming out of all of the wrong channels.
    Now when I watch movies or listen to music I switch to 5. sound in entertainment mode, but to make this work properly I have to open CMSS-3D. I then change it from xpand to stereo and put the slider at even center for 50%. If I use the default xpand mode the audio is way off coming out of all of the wrong channels.
    How do I make 5. render properly on vista

    We ended up getting iTunes cleanly uninstalled and were able to re-install without issue.  All is now mostly well.
    Peace...

  • Help needed with itunes

    help needed with itunes please tryed to move my itunes libary to my external hard drive itunes move ok and runs fin but i have none of my music or apps or anything all my stuff is in the itunes folder on my external hard drive but there is nothing on ituns how do i get it back help,please

    (Make sure the Music (top left) library is selected before beginning this.)
    If you have bad song links in your library, hilite them and hit the delete button. Then locate the folder(s) where your music is located and drag and drop into the large library window in iTunes ( where your tracks show up). This will force the tunes into iTunes. Before you start, check your preferences in iTunes specifically under the"Advanced" tab, general settings. I prefer that the 1st 2 boxes are unchecked. (Keep iTunes Music folder organized & Copy files to iTunes Music folder when adding to library). They are designed to let iTunes manage your library. I prefer to manage it myself. Suit yourself. If there is a way for iTunes to restore broken links other than locating one song at a time I haven't found it yet. (I wish Apple would fix this, as I have used that feature in other apps.) This is the way I do it and I have approx. 25,000 songs and podcasts and videos at present. Hope this helps.

Maybe you are looking for

  • Delta Load on DSO and Infocube

    Hi All,         I would like to know the procedure for the scenario mentioned below. Example Scenario: I have created a DSO with 10 characteristics and 3 keyfigure. i have got 10 Customers whose transactions are happening everyday. A full upload on t

  • Craigslist headers will not change color after clicking on it

    When I browse craigslist and click on a header to view the ad, when i go back, i have no way of knowing that i already clicked on a link because the color does not change. I have searched on the internet for a remedy but am unable to find one!

  • Why is virtual family crashing?

    i had recently perchased virtual familie for my mac.... then when i downloaded lion... virtual families started to crash

  • Managing iPhoto events on iPad

    Is there any way to merge/split iPhoto events on iPad?

  • Data Base Purification / Depuration

    Hi Guru's Now the company worked with SAP Retail, and I need to make a purification/ depuration of the BD, I can give some advice, suggestions or tips on where to start and which issues are most important in the process of purification because that's