have problem with understand how to resolve error in my code. Here it comes:

def counting_sort(some_list, max=100000):
    licznik = [0] * (max+1) 
    for x in some_list:
        licznik[x] = licznik[x]+1
    i=0
    for x in range(max+1):
        for y in range(licznik[x]):
            some_list[i]=x 
            i=i+1 
    return some_list.reverse()

def gen(number, b=100000):
    some_list = []
    return [some_list.append(random.randint(0, b)) for x in xrange(number)]

domain = [10000, 25000, 50000, 100000, 200000, 300000, 400000, 500000, 750000, 1000000]
for element in domain:
    print 'Results for: ' + str(element) + ' elements:'
    for j in range(0, 10):
        temp_list = gen(element)
        start = time.time()
        counting_sort(temp_list)
        end = time.time() - start
        print end

Your problem is in function gen(), the list comprehension should be ...

def gen(number, b=100000):
    return [random.randint(0, b) for x in xrange(number)]

Thanks a lot, Vegaseat!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.