Updated sorting_algorithms.py to python3

This commit is contained in:
madmaurice 2015-11-13 00:43:11 +01:00
parent cdc4a6f4f2
commit c54dfca75d

View file

@ -180,7 +180,7 @@ class SortTester:
data = list([ randint(0, size) for i in range(0,size) ])
for algorithm in self.algorithms:
print "Testing %s..." % algorithm.__name__
print("Testing %s..." % algorithm.__name__)
inst = algorithm()
c = data[:]
s = inst.sort(c)
@ -206,10 +206,10 @@ def main():
size= 1000
result = SortTester(list( SortAlgorithm.__subclasses__() )).test(size=size)
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():
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__':
main()