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 3 of 3

Thread: Insertion Sort

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    28
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Insertion Sort

    Hello! This isn't really a Java question, but I created a Java program that does Insertion Sort, and my Java teacher wants me to find the average case for it. My teacher gave me a hint by saying that the answer is (1/4)(n^2) + (1/4)(n), but now he wants me to prove it. I'm not exactly sure how to do that; I even looked up various explanations online, but none have helped. So, is anyone willing to give me a clear, brief description of how that is the average case? Thanks in advance!


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Insertion Sort

    Mmm, probability

    It's been a while since I've analyzed insertion sort, but if I remember correctly the performance time of Insertion Sort is proportional to the number of inversions. The more inversions, the less efficient the algorithm becomes. Unfortunately, I can't remember the math behind this.

    There's a better description of this here: 6.6 Performance Characteristics of Elementary Sorts

  3. #3
    Junior Member
    Join Date
    Jun 2010
    Posts
    28
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: Insertion Sort

    That helped me a little bit, but unfortunately I still don't completely understand. Thanks anyway; I really appreciate it!

Similar Threads

  1. Insertion and select in JDBC for two different databse
    By nrao in forum JDBC & Databases
    Replies: 1
    Last Post: November 15th, 2010, 08:14 PM
  2. Two insertion into RDBMS
    By nrao in forum JDBC & Databases
    Replies: 4
    Last Post: November 11th, 2010, 08:13 PM
  3. [SOLVED] Sorting a vector using insertion
    By DM21 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 25th, 2010, 05:36 PM
  4. bubble sort and selection sort on strings
    By Sir Saula in forum What's Wrong With My Code?
    Replies: 5
    Last Post: July 3rd, 2010, 09:44 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