0
favorites
favorites
0
comments
comments
Iterate through hashmap
This loop iterates through a hashmap. very simple. ...
0
favorites
favorites
0
comments
comments
Minecraft .txt from URL reader.
Title says all!
...
0
favorites
favorites
0
comments
comments
Android Wheel component
Android Wheel component ...
0
favorites
favorites
2
comments
comments
Counts the frequency of a word in a file.
Reads a file from the command line, asks the user to input a word. Counts the frequency of the word in the defined file. (just part of an assignment in college.) ...
0
favorites
favorites
1
comment
comment
Super
To simplify ...
0
favorites
favorites
4
comments
comments
Super fast sort algorithm
How my algorithm works (collapse sort), is to think how human normally arrange object.
Lets say we have:
3, 8, 5, 9 ,10, 2, 8, 6, 1, 7
First you find the highest value in the array which is 10
Second you create integer array the length of highest value you found
This then give us a list of index for the data to be store
So far the only comparison we done is finding high number
Now we loop all data and place it in the new array
3, 8, 5, 9 ,10, 2, 8, 6, 1, 7
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
_ | 1 | 1 | 1 | _ | 1 | 1 | 1 | 2 | 1 | 1
If you notice Array[8] has value of 2 because there is a repeat
After all arrange number have been store in a list
we can do a loop to place all those data back in array
As you see the is no comparison to slow the process down
1 | 2 | 3 | 5 | 6 | 7 | 8 | 8 | 9 | 10
If this sort algorithm has already been done i am going to be well gutted because so far i know that none of the sort works like my one. I only know 2 disadvantages to this algorithm is that:
1. If value in array is really big then the sort will slow down due unnecessary looping time
2. No matter what is the data is already sorted the time different from mostly ordered data and un-ordered data is the same
So far this could be the best sorting algorithm because is faster than any other tested sort
Here is my results:
For 300000 elements, the times are:
Type: Bubble Sort time: 6:42:875
Type: Insertion Sort time: 1:55:843
Type: Selection Sort time: 3:29:032
Type: Heap Sort time: 0:00:125
Type: Quicksort time: 0:00:046
Type: Collapse Sort time: 0:00:016 ...
0
favorites
favorites
1
comment
comment
Using JTree
There is only one way to use correctly a JTree but many ways to do it incorrectly. The basic mistake for a very beginner is to add a node with the 'add()' method. WRONG!
First use DefaultMutableTreeNode and DefaultMutableTreeModel, don;t use an interface or superclass, you will loose to much time.
Second, add a node to the model, see the snipet. ...