def findFrequency(arr, n, left, right, element):
count = 0
for i in range(left - 1, right):
if (arr[i] == element):
count += 1
return count
arr = [2, 8, 6, 9, 8, 6, 8, 2, 11]
n = len(arr)
print("Frequency of 2 from 1 to 6 = ",
findFrequency(arr, n, 1, 6, 2))
print("Frequency of 8 from 4 to 9 = ",
findFrequency(arr, n, 4, 9, 8))
No comments:
Post a Comment