BogoSort 2.0
-
Upload
henrique-pereira -
Category
Technology
-
view
1.572 -
download
1
description
Transcript of BogoSort 2.0
![Page 1: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/1.jpg)
BogoSort 2.0
Henr“ikke” G. G. Pereira
@ikkebr
![Page 2: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/2.jpg)
![Page 3: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/3.jpg)
http://en.wikipedia.org/wiki/Infinite_monkey_theorem
![Page 4: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/4.jpg)
![Page 5: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/5.jpg)
![Page 6: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/6.jpg)
BogoSort
![Page 7: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/7.jpg)
BogoSort
enquanto Lista não ordenada:
embaralhe Lista
![Page 8: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/8.jpg)
BogoSort (em Python)
![Page 9: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/9.jpg)
Quando usar
• Quando um código roda rápido demais.
• Quando se deseja mostrar a um cliente como ficaria o programa se ele fosse feito em Java.
• Em apresentações como essa.
![Page 10: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/10.jpg)
Análise (número de shuffles)
0
500
1000
1500
2000
2500
3000
3500
3 elementos 4 elementos 5 elementos 6 elementos
Mínimo de Shuffles
Máximo de Shuffles
Média de Shuffles
![Page 11: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/11.jpg)
+ Benchmark
0
5000
10000
15000
20000
25000
30000
35000
3 elementos 4 elementos 5 elementos 6 elementos 7 elementos
Mínimo de Shuffles
Máximo de Shuffles
Média de Shuffles
![Page 12: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/12.jpg)
++ Benchmark
0
200000
400000
600000
800000
1000000
1200000
1400000
3 elementos 4 elementos 5 elementos 6 elementos 7 elementos 8 elementos 9 elementos
Mínimo de Shuffles
Máximo de Shuffles
Média de Shuffles
![Page 13: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/13.jpg)
Listas com tamanho 10
0
1000000
2000000
3000000
4000000
5000000
6000000
3 elementos 4 elementos 5 elementos 6 elementos 7 elementos 8 elementos 9 elementos 10 elementos
Mínimo de Shuffles
Máximo de Shuffles
Média de Shuffles
![Page 14: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/14.jpg)
Extrapolando um pouco
![Page 15: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/15.jpg)
![Page 16: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/16.jpg)
Conclusões
• O BogoSort funciona bem até 7 elementos.
![Page 17: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/17.jpg)
Conclusões
• Com o aumento do número de elementos em uma lista, o tempo de execução do BogoSorttende ao tempo de inicialização do Eclipse.
![Page 18: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/18.jpg)
Conclusões
• A sorte é relativa.
![Page 19: BogoSort 2.0](https://reader034.fdocument.pub/reader034/viewer/2022051816/54595c9bb1af9f33608b5446/html5/thumbnails/19.jpg)
Conclusões
• Python é melhor que Java.