Updated sorting_algorithms.py to python3
This commit is contained in:
parent
cdc4a6f4f2
commit
c54dfca75d
1 changed files with 3 additions and 3 deletions
|
@ -180,7 +180,7 @@ class SortTester:
|
||||||
data = list([ randint(0, size) for i in range(0,size) ])
|
data = list([ randint(0, size) for i in range(0,size) ])
|
||||||
|
|
||||||
for algorithm in self.algorithms:
|
for algorithm in self.algorithms:
|
||||||
print "Testing %s..." % algorithm.__name__
|
print("Testing %s..." % algorithm.__name__)
|
||||||
inst = algorithm()
|
inst = algorithm()
|
||||||
c = data[:]
|
c = data[:]
|
||||||
s = inst.sort(c)
|
s = inst.sort(c)
|
||||||
|
@ -206,10 +206,10 @@ def main():
|
||||||
size= 1000
|
size= 1000
|
||||||
result = SortTester(list( SortAlgorithm.__subclasses__() )).test(size=size)
|
result = SortTester(list( SortAlgorithm.__subclasses__() )).test(size=size)
|
||||||
for cls, r in result.items():
|
for cls, r in result.items():
|
||||||
print "%-12s: %10d, %d compares, %d swaps" % (cls.__name__, r[0]+r[1], r[0],r[1])
|
print("%-12s: %10d, %d compares, %d swaps" % (cls.__name__, r[0]+r[1], r[0],r[1]))
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
print HeapSort().sort([randint(0,500) for i in range(0,100)])
|
print(HeapSort().sort([randint(0,500) for i in range(0,100)]))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue