Mean, Median, and Mode Problem Statement
Given an integer array ARR
of size N
, you need to compute the following three statistical measures:
- Mean: Implement the function
mean()
to calculate the mean of the array. - Median: Implement the function
median()
to calculate the median of the array. - Mode: Implement the function
mode()
to determine the mode of the array.
Return these measures in the specified format.
Example:
Input:
ARR = {1, 1, 2, 2, 3, 3, 4}
Output:
Mean: P Q
Median: P Q
Mode: 1
Explanation:
For the given array, the mode will be 1, as it is the smallest of all the possible modes (1, 2, and 3).
Constraints:
1 <= T <= 5
1 <= N <= 105
1 <= ARR[i] <= 106
- Where
ARR[i]
denotes theith
element of the array. - Time limit: 1 sec
Note:
- Mean and Median should be returned in the form
P/Q
, whereP
andQ
are coprime integers, andQ ≠ 0
. - If multiple elements have the same highest frequency, return the smallest one as the mode.

AnswerBot
4mo
Implement functions to calculate mean, median, and mode of an integer array.
Calculate mean by summing all elements and dividing by total count
Calculate median by sorting array and finding middle eleme...read more
Help your peers!
Add answer anonymously...
Mobikwik Software Developer Intern interview questions & answers
A Software Developer Intern was asked Q. Mean, Median, and Mode Problem Statement Given an integer array ARR of size N, y...read more
A Software Developer Intern was asked Q. Triplets with Given Sum Problem Given an array or list ARR consisting of N integ...read more
A Software Developer Intern was asked Q. Diamond Pattern Grid Problem Create a grid pattern of size R rows and C columns,...read more
Popular interview questions of Software Developer Intern
A Software Developer Intern was asked Q1. Mean, Median, and Mode Problem Statement Given an integer array ARR of size N, y...read more
A Software Developer Intern was asked Q2. Triplets with Given Sum Problem Given an array or list ARR consisting of N integ...read more
A Software Developer Intern was asked Q3. Diamond Pattern Grid Problem Create a grid pattern of size R rows and C columns,...read more
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

