Write an algorithm in Python to count the number of occurrences of a given element in a given array.
def count_occurrences(array, element): 
    count = 0
    for i in range(len(array)): 
        if array[i] == element: 
            count += 1
    return count