- Stooge sort is a recursive sorting algorithm with a time complexity of O(n^(log 3 / log 1.5) ) = O(n^(2.7095...)). The running time of the algorithm is thus slower compared to efficient sorting algorithms, such as Merge sort, and is even slower than Bubble sort, a canonical example of a fairly inefficient and simple sort.
- Step 1 : If value at index 0 is greater than value at last index, swap them.
- Step 2: Recursively,
- Stooge sort the initial 2/3rd of the array.
- Stooge sort the last 2/3rd of the array.
- Stooge sort the initial 2/3rd again to confirm.
- This java example shows how to sort an element of Java ArrayList using Stooge Sort method of Collections class.
- The program firstly assign some values including person's atttributes to its object and performs sort process in terms of each attribute title. All sort process is implemented by Turkish alphabetical order.
- src
- stoogesort
- StoogeSortProcess.java
- main
- Main.java
- model
- Person.java
- util
- DefineValues.java
- ShowProcess.java
- stoogesort
Files Names | Information |
---|---|
StoogeSortProcess.java | Implementing Stooge Sort Process by Turkish alphabetical order |
Person.java | Defining it as a POJO |
Main.java | Handle with all project files to run the program |
ShowProcess.java | Showing all information about Person Object as output |
DefineValues.java | Filling its attributes into Person Object |