Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Insert Sort Algorithm

807589Jan 3 2009 — edited Jan 3 2009
Hi,
I have to programming with java code the Insert Sort Algorithm . Every iteration of insertion sort removes an element from the input data, inserting it into the correct position in the already-sorted list, until no input elements remain.
The algoritgm put each element in a empty list , for example:
List <Object> x = new ArrayList<Object>();
Object o = new .... ;
x.insertSort(o);
ex:
x.insertSort(9);
x.insertSort(12);
x.insertSort(1);
x.insertSort(50)
x.insertSort( 0 ) ;

x.toString() >  0, 1 , 9 , 12 , 50
This operation put the object o in x by comparing y ( y attribute of o , o.y ) where y is a double.
Someone has this algorithm in java (even in pseudocode) ?

Thanks for all ! ;)

Edited by: smanuel on Jan 3, 2009 12:50 AM

Edited by: smanuel on Jan 3, 2009 1:18 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 31 2009
Added on Jan 3 2009
9 comments
270 views