File tree 4 files changed +34
-15
lines changed
4 files changed +34
-15
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ def isSorted(collection):
40
40
41
41
if __name__ == '__main__' :
42
42
import sys
43
-
43
+ '''
44
44
# For python 2.x and 3.x compatibility: 3.x has not raw_input builtin
45
45
# otherwise 2.x's input builtin function is too "smart"
46
46
if sys.version_info.major < 3:
@@ -50,4 +50,6 @@ def isSorted(collection):
50
50
51
51
user_input = input_function('Enter numbers separated by a comma:\n ')
52
52
unsorted = [int(item) for item in user_input.split(',')]
53
+ '''
54
+ unsorted = list (range (10 ,1 ,- 1 ))
53
55
print (bogosort (unsorted ))
Original file line number Diff line number Diff line change 11
11
"""
12
12
13
13
from __future__ import print_function
14
-
14
+ import time
15
15
16
16
def bubble_sort (collection ):
17
17
"""Pure implementation of bubble sort algorithm in Python
@@ -41,6 +41,7 @@ def bubble_sort(collection):
41
41
42
42
if __name__ == '__main__' :
43
43
import sys
44
+ '''
44
45
# For python 2.x and 3.x compatibility: 3.x has not raw_input builtin
45
46
# otherwise 2.x's input builtin function is too "smart"
46
47
if sys.version_info.major < 3:
@@ -50,4 +51,9 @@ def bubble_sort(collection):
50
51
51
52
user_input = input_function('Enter numbers separated by a comma:\n ')
52
53
unsorted = [int(item) for item in user_input.split(',')]
54
+ '''
55
+ tstart = time .clock ()
56
+ unsorted = list (range (5000 ,1 ,- 1 ))
53
57
print (bubble_sort (unsorted ))
58
+ tend = time .clock ()
59
+ print ("read: %f s" % (tend - tstart ))
Original file line number Diff line number Diff line change @@ -54,12 +54,18 @@ def heap_sort(unsorted):
54
54
return unsorted
55
55
56
56
if __name__ == '__main__' :
57
- import sys
58
- if sys .version_info .major < 3 :
59
- input_function = raw_input
60
- else :
61
- input_function = input
62
-
63
- user_input = input_function ('Enter numbers separated by a comma:\n ' )
64
- unsorted = [int (item ) for item in user_input .split (',' )]
65
- print (heap_sort (unsorted ))
57
+ import sys
58
+ import time
59
+ if sys .version_info .major < 3 :
60
+ input_function = raw_input
61
+ else :
62
+ input_function = input
63
+ tstart = time .clock ()
64
+ unsorted = list (range (150000 ,1 ,- 1 ))
65
+ #print(sort(unsorted))
66
+ print (heap_sort (unsorted ))
67
+ tend = time .clock ()
68
+ print ("read: %f s" % (tend - tstart ))
69
+ #user_input = input_function('Enter numbers separated by a comma:\n')
70
+ #unsorted = [int(item) for item in user_input.split(',')]
71
+ #print(heap_sort(unsorted))
Original file line number Diff line number Diff line change 11
11
"""
12
12
from __future__ import print_function
13
13
from random import shuffle
14
-
14
+ import time
15
15
16
16
def sort (collection ):
17
17
shuffle (collection )
@@ -61,6 +61,11 @@ def quick_sort(collection):
61
61
else :
62
62
input_function = input
63
63
64
- user_input = input_function ('Enter numbers separated by a comma:\n ' )
65
- unsorted = [int (item ) for item in user_input .split (',' )]
66
- print (sort (unsorted ))
64
+ #user_input = input_function('Enter numbers separated by a comma:\n')
65
+ #unsorted = [int(item) for item in user_input.split(',')]
66
+ tstart = time .clock ()
67
+ unsorted = list (range (500 ,1 ,- 1 ))
68
+ #print(sort(unsorted))
69
+ print (quick_sort (unsorted ))
70
+ tend = time .clock ()
71
+ print ("read: %f s" % (tend - tstart ))
You can’t perform that action at this time.
0 commit comments