Counting Sort 1

  • + 0 comments
    def countingSort(arr):
        # create an array of zeros with the length (100)
        result = [0 for i in range(100)]
        # iterate the array and add one to the index everytime it see the same number as the index
        for i in arr:
            result[i] = result[i] + 1
        print(result)
        return result