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 - memory usage

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Insertion Sort - memory usage

    what is the best way to get O(n) memory usage in insertion sort?
    Last edited by lovon; October 2nd, 2011 at 06:10 AM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,307
    Thanks
    181
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: Insertion Sort - memory usage

    See Insertion sort - Wikipedia, the free encyclopedia

    If you are still confused, please post a more specific question about what you are confused about.

  3. #3
    Junior Member
    Join Date
    Nov 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Insertion Sort - memory usage

    Hi!!!!
    This is insertion sort algorithm

    public class insertSort {

    public static void main(String[] args) {

    int[] array={3,4,5,6,7,8,1,2,3};

    int temp;
    for(int i=0;i<array.length;i++)
    for(int j=i;j>0;j--)
    if(array[j]>array[j-1]){
    temp=array[j];
    array[j]=array[j-1];
    array[j-1]=temp;
    }

    for(int i=0;i<array.length;i++)
    System.out.print(array[i]+" ");
    System.out.println();
    }

    }


    Think how here to implement data Structures.
    Hope this helps

Similar Threads

  1. 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
  2. Using a Generic Insertion Sort method
    By dubois.ford in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 6th, 2011, 05:08 PM
  3. Insertion Sort
    By Kimimaru in forum Algorithms & Recursion
    Replies: 2
    Last Post: December 6th, 2010, 05:26 AM
  4. Memory Handling -de allocate memory in Java
    By 19world in forum Java Theory & Questions
    Replies: 4
    Last Post: June 15th, 2010, 04:05 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