Given an array arr[] of size N, the task is to find the frequency of each distinct element present in the given array.

Examples:

Input: arr[] = { 1, 100000000, 3, 100000000, 3 }

Output: { 1 : 1, 3 : 2, 100000000 : 2 }

Explanation:

Distinct elements of the given array are { 1, 100000000, 3 }

Frequency of 1 in the given array is 1.

Frequency of 100000000 in the given array is 2.

Frequency of 3 in the given array is 2.

Therefore, the required output is { 1 : 1, 100000000 : 2, 3 : 2 }

Input: arr[] = { 100000000, 100000000, 800000000, 100000000 }

Output: { 100000000 : 3, 800000000 : 1}

#arrays #c #c programs #mathematical #searching #sorting #binary search #frequency-counting #quick sort

C Program to Count Frequency Of Each Element in an Array
1.20 GEEK