Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Problem with a binary insertion sort method

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with a binary insertion sort method

    My task is to write a program to sort (a part of) a given list of comparable elements using binary insertion sort method. Binary insertion method is a modified insertion method that uses binary search to find the insertion point. Implementation has to be stable (has to preserve the original order of equal elements). There are three parameters to program:
    a - the list;
    left - starting index (included);
    right - ending index (excluded).

    The method signature is:

    static public <T extends Object & Comparable<? super T>>
    void biSort (List<T> a, int left, int right)

    Piece of code
    The method starts from line 130, there are tests and other sorting methods in this program. I dont know why my method doesnt do the job, so any help is more than welcome. Ive been workin on that method nearly week, but due to lack of skills in java it doesnt work out.

    Best wishes,

    Kert


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Problem with a binary insertion sort method

    I dont know why my method doesnt do the job, so any help is more than welcome. Ive been workin on that method nearly week, but due to lack of skills in java it doesnt work out.
    What do you mean by the above? "Doesn't do the job," and "Doesn't work out" aren't specific enough. You might read this article to help you write posts that get helpful responses.

  3. #3
    Junior Member
    Join Date
    Sep 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem with a binary insertion sort method

    Numbers list goes to wrong order, unsorted.

    --- Update ---

    Sorry i couldnt edit my post. I get java.lang.RuntTimeException. Heres the JUnit test which checks for errors Test program

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Problem with a binary insertion sort method

    Have you ever successfully written a program that does sorting using insertion sort? I suggest you step back from the rather large program you've written and spend some time with just doing the sorting part using insertion sort and then binary insertion sort. You can find many helpful articles on the topic searching the Internet.

  5. #5
    Junior Member
    Join Date
    Sep 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem with a binary insertion sort method

    I have, but the examples and guides are made with regular arrays of integers. But at my task, i have to use ArrayList and Comparable methods, i dont know why these methods get me confused.

Similar Threads

  1. Insertion Sort - memory usage
    By lovon in forum Algorithms & Recursion
    Replies: 2
    Last Post: November 6th, 2011, 04:00 PM
  2. Insertion Sort on a Doubly Linked List
    By Kaisshau in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 7th, 2011, 11:18 PM
  3. Using a Generic Insertion Sort method
    By dubois.ford in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 6th, 2011, 06:08 PM
  4. Insertion Sort
    By Kimimaru in forum Algorithms & Recursion
    Replies: 2
    Last Post: December 6th, 2010, 06:26 AM
  5. Pseudo code of insertion sort linked list
    By sungirl in forum Algorithms & Recursion
    Replies: 1
    Last Post: May 23rd, 2010, 09:25 AM