i've got my radix sort working property in all but one aspect.
i put in this list for aList:['2356', '2346', '2346', '124', '1234', '34587', '6780', '4567', '16379', '12', '3467']
and for some reason it tells me that my max length is 4 saying that 6780 is my max number, which it really isn't, 34587 is my largest number so why does it tell me that this is my max?
CODE
from queque import FrontZeroQueue
def radixSort(aList):
bigQueue = FrontZeroQueue()
newList = aList.split(",")
print newList
print max(newList)
tot= len(max(newList))
print tot
passes = 1
bins = []
for num in xrange(10):
q = FrontZeroQueue()
bins.append(q)
for nums in newList:
bigQueue.enqueue(int(nums))
while passes !=tot+1:
while len(bigQueue) > 0:
curNum=bigQueue.dequeue()
if passes == 1:
rem = curNum % 10
bins[rem].enqueue(curNum)
elif passes >=2:
rem =curNum % (10**passes)
rem = rem/ (10**(passes-1))
bins[rem].enqueue(curNum)
while not bins[0].isEmpty():
bigQueue.enqueue(bins[0].dequeue())
while not bins[1].isEmpty():
bigQueue.enqueue(bins[1].dequeue())
while not bins[2].isEmpty():
bigQueue.enqueue(bins[2].dequeue())
while not bins[3].isEmpty():
bigQueue.enqueue(bins[3].dequeue())
while not bins[4].isEmpty():
bigQueue.enqueue(bins[4].dequeue())
while not bins[5].isEmpty():
bigQueue.enqueue(bins[5].dequeue())
while not bins[6].isEmpty():
bigQueue.enqueue(bins[6].dequeue())
This post has been edited by brramiz: 22 Oct, 2009 - 02:21 PM