net.sf.jsort.sort
Class InsertSort
java.lang.Object
net.sf.jsort.sort.AbstractSort
net.sf.jsort.sort.InsertSort
- All Implemented Interfaces:
- CompareSort, SortAlgorithm
public final class InsertSort
- extends AbstractSort
Implementation of the Insert sort algorithm.
The general idea of this algorithm is start with an already
sorted array (the first element of the array).
The algorithm starts to insert a new element in
the correct position (thus maintaining the array sorted),
until the last element is inserted.
At worst case it will compare all element with all elements -
letting the complexity O(n^2)
.
- Author:
- Domingos Creado
- See Also:
- http://en.wikipedia.org/wiki/Insertsort
Method Summary |
void |
sort(java.lang.Object[] a,
java.util.Comparator comparator,
int start,
int end)
Sort a specific range of the list, using the specified comparator. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
InsertSort
public InsertSort()
sort
public void sort(java.lang.Object[] a,
java.util.Comparator comparator,
int start,
int end)
- Description copied from interface:
CompareSort
- Sort a specific range of the list, using the specified comparator.
- Specified by:
sort
in interface CompareSort
- Specified by:
sort
in class AbstractSort
- Parameters:
a
- to be sort
Copyright © 2005-2008 Domingos Creado. All Rights Reserved.