# # This file contains the Python code from Program 3.5 of # "Data Structures and Algorithms # with Object-Oriented Design Patterns in Python" # by Bruno R. Preiss. # # Copyright (c) 2003 by Bruno R. Preiss, P.Eng. All rights reserved. # # http://www.brpreiss.com/books/opus7/programs/pgm03_05.txt # def bucketSort(a, n, buckets, m): for j in range(m): buckets[j] = 0 for i in range(n): buckets[a[i]] += 1 i = 0 for j in range(m): for k in range(buckets[j]): a[i] = j i += 1