Last active
February 22, 2016 20:27
-
-
Save pudov/c746b7abfc8bc4e96b74 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from random import sample | |
| from time import time | |
| def buble_sort(a): | |
| for i in xrange(len(a)): | |
| for j in xrange(1, len(a) - i): | |
| if a[j-1] > a[j]: | |
| temp = a[j] | |
| a[j] = a[j-1] | |
| a[j-1] = temp | |
| l = sample(xrange(10000000), 10000) | |
| s = time() | |
| buble_sort(l) | |
| e = time() | |
| print "took:", (e-s), "seconds" |
Author
Author
pypy bubble.py
took: 0.678442001343 seconds
Author
g++ -O2 -std=c++11 bubble.cpp && ./a.out
took: 335.981 ms
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
python bubble.py
took: 9.38592505455 seconds