[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

r8 my sort algorithm /tech/ i call it ubersoftsort

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 27
Thread images: 4

File: ubersoft.png (75KB, 760x872px) Image search: [Google]
ubersoft.png
75KB, 760x872px
r8 my sort algorithm /tech/

i call it ubersoftsort
>>
>>57454014
How do I sort negative numbers? :(
>>
>>57454064
Add absolute value of minimum element to all, sort, subtract
>>
pretty much a synchronous sleep sort
>>
>>57454014
Mine's better:
def sorting(array):
return sorted(array)

def main():
array = [2, 3, -1, 1, 5, 4, 0, -2]
new_array = sorting(array)
print(new_array)

if __name__ == "__main__":
main()
>>
>>57454185
Not OP but you're more of a faggot than OP.
>>
File: ubersoftv3.png (58KB, 493x695px) Image search: [Google]
ubersoftv3.png
58KB, 493x695px
here's my final version of ubersoftsort.

O(n*k) its the best algorithm out there right now.

i'm very proud of myself, it can even sort negative numbers.
>>
>>57454286
>best algorithm out there right now
Not really. Most of the times k is going to be close to n which leads to O(n^2).
>>
heapsort best sort
>>
>2016
>not using sleepsort
Are you all Pajeets or what?
>>
>using python 2.x when python 3.x is a thing
>>
Just looking at it, I think this has a bug.
>>
>>57454014
Nice sleepsort you retard
>>57454469
No, it's just sleepsort
>>
>>57454286
Comparing it to randomized quicksort you use 2 times more memory, and is only faster if the range of values is smaler than log(list size) wich is rare in a real world scenario.
i should probably be comparing it to counting or radix sort but im not remembering them very well atm.
>>
File: variable names.png (78KB, 828x763px) Image search: [Google]
variable names.png
78KB, 828x763px
>>57454014
That's nothing, rate THIS
>>
>>57454612
>Displaying tabs as arrows
>Javascript
>Write once shitty code
cancer/10.
>>
>>57454612
>no spacing anywhere
kys yourself
>>
>while true

Fucking kill yourself
>>
>>57454014
>>57454286

That's going to be a really inefficient sort if there is a huge difference between the largest and smallest items.

For example:

item = [2, 3, 1, 9999999, 2, 7]


is going to take a crazy amount of time, relative to a more efficient algorithm.
>>
>>57454868
I think you can optimize it by giving multidigit numbers a higher substraction.
>>
>>57454658
>kill yourself yourself
>>
>>57454014
>not in-place
>not stable
>not O(nlogn)

I rate 1/10. The 1 is only because it sorts.
>>
>>57455370
Do you even know what being stable means?
>>
import random

items = [2, 3, 1, 5, 2, 7]

sorted=False
while not sorted:
sorted=True
random.shuffle(items)

for i in range(len(items)-1):
if items[i]>items[i+1]:
sorted=False
break

print items
>>
>>57458753
It works
>>
>>57454612
And now I'm blind. Thanks anon!
>>
>>57454612
ARROWS
Thread posts: 27
Thread images: 4


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.