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

Thread: Converting Insertion Sort pseudocode to running Java code

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

    Default Converting Insertion Sort pseudocode to running Java code

    Hello I been stuck on this for quite some time. I tried to convert this Insertion Sort pseudocode into java but dont get the right output. Here is the pseudocode.

    INSERTION-SORT(A)
    1 for j ← 2 to length[A]
    2 do key ← A[j]
    3 ▹ Insert A[j] into the sorted sequence A[1 j - 1].
    4 i ← j - 1
    5 while i > 0 and A[i] > key
    6 do A[i + 1] ← A[i]
    7 i ← i - 1
    8 A[i + 1] ← key


  2. #2
    Member
    Join Date
    May 2011
    Location
    west palm beach, FL
    Posts
    189
    My Mood
    Tired
    Thanks
    41
    Thanked 11 Times in 10 Posts

    Default Re: Converting Insertion Sort pseudocode to running Java code

    what output did you get and what output are you supposed to get? could you post the code that gives you the wrong output?

Similar Threads

  1. Replies: 6
    Last Post: March 1st, 2013, 02:06 PM
  2. Insertion Sort - memory usage
    By lovon in forum Algorithms & Recursion
    Replies: 2
    Last Post: November 6th, 2011, 04:00 PM
  3. Need help converting Pseudocode to java
    By firebyrd in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 5th, 2011, 06:28 AM
  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, 10:25 AM