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
4
comments
comments
PHP Keyword Cloud Generator
PHP Keyword Cloud Generator
- Scans the given text for the most common words
- This example also generates a sample of how to use the output ...
0
favorites
favorites
3
comments
comments
HTML Mail Form
Form to send POST data to a php file and send its data to a email. ...
0
favorites
favorites
3
comments
comments
C# Text to Speech (and Speech to Text) in a few lines of code
this is always fun to play with...
create a new form, 2 buttons (btnSpeak and btnListen) and a text box (textBox1)...
add the following code and start converting Text to Speech and Speech to Text...
comes standard with Visual Studio...
...
64
favorites
favorites
3
comments
comments
Submit a form by hitting the enter button inside an input field with jQuery
Users a used to submit a form without clicking the submit button of a form. They expect to get to the next step or page just by hitting the enter button. The code snippets binds the keypress action to all form with the specific CSS-class "enter-submit". In order to bind the action also for ajax-loaded elements we use the binding function "live". ...
0
favorites
favorites
2
comments
comments
REDIMENCIONAR IMAGENES
ES PARA REDIMCNEIONAR ...
0
favorites
favorites
2
comments
comments
PHP String Crop
Useful little function that finds and returns a chunk of a string between point A and point B.. ...
0
favorites
favorites
2
comments
comments
Exporting a QTableWidget to a CSV File
This little piece of code exports a QTableWidget to a CSV File. The filename is stored in the QLineEdit, and the QTableWidget is passed as a parameter.
No error checking, just quick and dirty. ...
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
2
comments
comments
Unique string generator
Generates a unique string. Cool if you need generate file names or stuff like that. ...