Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
What are Averages?
3.
Finding Average from a Set of Numbers
3.1.
Using Formula
3.2.
Using Assumed Average Approach
4.
Some Direct Formulae
5.
Understanding Questions Related to Averages
5.1.
Example
5.2.
Solution
6.
Type 1
6.1.
Example 1
6.2.
Solution 1
6.3.
Example 2
6.4.
Solution 2
7.
Type 2
7.1.
Example 1
7.2.
Solution 1
7.3.
Example 2
7.4.
Solution 2
7.5.
Example 3
7.6.
Solution 3
8.
Type 3
8.1.
Example 1
8.2.
Solution 1
8.3.
Example 2
8.4.
Solution 2
9.
Concept of Weighted Average
9.1.
Example 1
9.2.
Solution 1
9.3.
Example 2
9.4.
Solution 2
10.
Frequently Asked Questions
10.1.
What is average?
10.2.
What is the weighted average?
10.3.
How do you calculate the average?
10.4.
Do average and sum mean the same thing?
10.5.
What is the use of averages?
11.
Conclusion
Last Updated: Mar 27, 2024
Easy

Averages

Author Gaurangi Tyagi
8 upvotes
Master Power BI using Netflix Data
Speaker
Ashwin Goyal
Product @
18 Jun, 2024 @ 01:30 PM

Introduction

Finding averages of a set of numbers is something we all did in mathematics during our school days, and we have to do it in college.

That is because averages-related questions are asked in company aptitude rounds. The aptitude test eliminates the students who score below the cut-off marks, so it is essential to ace the test.

averages

If you are looking for aptitude preparation, you may check out the aptitude preparation guided path on Coding Ninjas Studio, where all the necessary domains in aptitude are covered in-depth.

This blog will discuss averages in detail.

What are Averages?

In simple terms, "average" can be defined as a number that measures the central tendency of a group of numbers. In other words, it estimates where the center point of the set of numbers lies. The average is also known as the mean.

For Example:

Consider that you are trying to calculate the average height of a group of four people. The measurements are 140 cm, 142 cm, 144 cm, and 146 cm. The average height can be calculated as shown below:

Average Height = (140 + 142 + 144 + 146)/4 = 572/4 = 143 cm.

example
Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Finding Average from a Set of Numbers

The above example of finding the average height was quite simple. There is a 0.0001% chance that such questions will be asked in interviews and competitive examinations. Before moving to the questions, it is essential to understand how to find the average of a set of numbers.

You can find averages using any of the following methods.

Using Formula

An average of a group of numbers can be easily found using the standard formula.

Average = Sum of the numbers / Total no. of numbers


Let's consider an example of the petrol prices over five consecutive months and find the average price using the standard formula.

Petrol prices are as follows, ₹90 for Month 1, ₹88 for Month 2, ₹99 for Month 3, ₹102 for Month 4, and ₹95 for Month 5, respectively.

Average = (90 + 88 + 99 + 102 + 95) / 5

The average price of petrol is ₹94.8 over five months.

Using Assumed Average Approach

The standard approach to finding the average is relatively straightforward, and you may use it when finding the average from a set of few numbers or when the numbers are small. However, as the count of numbers increases, summing up the numbers is not an efficient approach, especially when solving questions in an examination where every minute matters.

Another approach is the "Assumed Average" approach, wherein you will assume an average value from the set of numbers. The following are the steps to find the average using the assumed average approach:

Step 1: You have to assume an average.

Step 2: Calculate how much the given numbers deviate from the assumed average.

Step 3: Calculate the sum of all the deviations (i.e., the total deviation).

Step 4: Calculate the average deviation with the help of the following formula:
	      Average deviation = Total deviation / Total no. of numbers.
		
Step 5: Correct average = Assumed Average + Average Deviation.

 

Let's try to solve the above problem of finding the average price of petrol over five months using this approach.

Step 1: Consider the assumed mean/average to be 96.

Step 2: Calculate the deviation

Petrol Price

Assumed Average

Deviation

90

96

-6

88

96

-8

99

96

3

102

96

6

95

96

-1

Step 3: The net sum of these deviations is (-6 + (-8) + 3 + 6 + (-1)) = -6

Step 4: Average deviation = -6/5 = -1.2

Step 5: Correct average = 96 + (-1.2) = 94.8 

Note - The average is 94.8, the same value obtained using the standard formula.


Tip from Ninja:  Even though you may take any value as an assumed average value, it is recommended that you take the assumed average to be nearly equal to one of the given values for simple calculations.

Some Direct Formulae

The expressions mentioned below are quite handy when solving questions.

  1. Average of the first n natural numbers = (n + 1) /2
     
  2. Average of the squares of first n natural numbers = {(n + 1)(2n + 1)}/6
     
  3. Average of the cubes of first n natural numbers = {n(n + 1)2}/4
     
  4. Average of first n natural odd numbers = n
     
  5. Average of first n natural even numbers = n + 1


Let's find the averages using these direct formulas.

Find the average of - 

Formula

Solution

First ten natural numbers (n + 1) /2 (10 + 1)/2 = 5.5
Squares of the first ten natural numbers {(n + 1)(2n + 1)}/6 {(10 + 1)(2*10 + 1)}/6 = 38.5
Cubes of the first ten natural numbers n(n + 1)^2/4 {10(10 + 1)^2}/4 = 10 * 121/4 = 302.5
First ten odd natural numbers n 10
First ten even natural numbers n + 1 11

Using the standard formula and the assumed average approach to level up your average finding skills, you can find these averages on your own. The answer will be the same.

Understanding Questions Related to Averages

So far, we have seen how to find averages using two approaches and did some basic questions. However, the questions asked in reality are quite different. This section will introduce you to common question situations and demonstrate how to solve them.  Let us look at an example of how questions are asked in exams.

Example

So consider that you are given that "the average price of a set of 10 T-Shirts of X brand is 400." That means the total cost of 10 T-Shirts of brand X is 10 * 400 = 4000.
The same question can be twisted as, "the average price of a set of n T-Shirts of X brand is 400. The total cost of n T-shirts is 4000; find the number of T-Shirts."

Solution

Although the question seems complicated, it is easy to solve. To find the number of t-shirts, we can follow these steps.

  • Using the standard formula for finding the average:
    Average price per T-Shirt = Total cost of T-Shirts / Total number of T-shirts.
     
  • To find the total number of T-shirts, we can re-write this as:
    Total number of T-shirts = Total cost of T-shirts/ Average price per T-shirt.
     
  • Now, let's substitute the values in this relation.
    Total number of T-shirts = 4000/400 = 40.


You see how simple questions are twisted so that they appear hard. Hence, it is vital to understand the questions that are commonly asked. It will help you avoid confusion while solving the questions.

Let us now look at the types of questions you may encounter in competitive exams.

Type 1

One of the common types of questions revolves around the following situation. You will be given the average of n numbers, a new number is added to the group, and the new average after adding a number will be provided. You need to find the new number.


To understand it better, let us consider an example based on the given situation.

Example 1

Consider that the average marks of a student in five subjects are 86. The student forgot to add the marks of one subject; after adding the marks of the 6th subject, the new average is 88. Find the marks in the sixth subject.

Solution 1

Average marks in 5 subjects = 86

Total marks in 5 subjects = Average marks in 5 subjects * Count of subject 
                                             =  86 * 5  
                                             = 430


Average marks in 6 subjects = 88

Total marks in 6 subjects = Average marks in 6 subjects * Count of subjects
                                             = 88 * 6  
                                             = 528


Marks in 6th subject = Total marks in 6 subjects - Total marks in 5 subject 
                                     = 528 - 430 
                                     = 98


Another variation is that you will be given the average of n numbers, a number is removed from the group, and the new average after removing the number is also given. You have to find the number that was removed from the group.


To understand it better, let us consider an example based on the given situation.

Example 2

Consider that you are given average marks of 5 subjects to be 96. The student now calculates the average of four subjects; the new average is 98. Find the subject's marks that he did not consider while calculating the average of 4 subjects.

Solution 2

Average marks in 5 subjects =  96

Total marks in 5 subjects = Average marks in 5 subjects * Count of subjects
                                             =  96 * 5
                                             = 480
 

Average marks in 4 subjects = 98

Total marks in 4 subjects = Average marks in 4 subjects * Count of subjects 
                                            = 98 * 4 
                                            = 392

Let x be the marks in the subject that he did not consider while calculating the average of 4 subjects.
x = Total marks in 5 subjects - Total marks in 4 subjects
   = 480 - 392 
   = 88
 

Hence the subject's mark, which he does not take into account while calculating the average of 4 subjects, is 88.

Type 2

The second type of question revolves around this situation. You will be given an average of n numbers, more than one number is added to the group, and the new average after adding the numbers will be given. You need to compute the average of the new numbers added.

Let us now look at an example based on the given situation.

Example 1

The average of 5 numbers is 86. After adding two numbers, the new average becomes 85. Find the average of new numbers added.

Solution 1

Total of two numbers = (sum of 7 numbers) - (sum of 5 numbers)  

                                        = (Average of 7 numbers * 7) - (Average of 5 numbers * 5) 

                                        = (85 * 7) - (86 * 5) = 595 - 430 = 165
 

Average of two numbers that were added = 165/2 = 82.5
 

Similarly, a possible variation is that the average of n numbers will be given, m numbers are removed where m < n, and the new average will be given. You need to calculate the average of the numbers removed.

Let's look at an example based on the given situation.

Example 2

Consider that the average marks of a student in 5 subjects are 86. The student now removes the marks of 2 subjects, and the new average is 92. Find the average marks in those two subjects.

Solution 2

Sum of marks in two subjects = (sum of marks in 5 subjects) - (sum of marks in 3 subjects)
                                                      = (5 * 86) - (92 * 3)
                                                      = 430 - 276  
                                                      = 154

Average marks in those two subjects = 154/2 = 77.

Let us now look at another example of this situation.

Example 3

After 120 innings, a batsman has an average of 55. And he realizes that he is going to play 180 innings more, and he wants an average of 100 runs per inning. So what should be the average of the remaining 180 innings?

Solution 3

The score of 180 innings = (Score of 300 innings) - (Score of 120 innings)

The score of 180 innings = (Average of 300 innings * 300) - (Average of 120 innings * 120)

The score of 180 innings = (100 * 300) - (55 * 120)

The score of 180 innings = 30000 - 6600

The score of 180 innings = 23400

Average score of 180 innings = 23400/180 = 130

Type 3

The third type of question revolves around this situation. You will be given the average of n numbers. A number is replaced in the group, and the new average will be given after the number replacement. You need to find the number that was replaced.

Note that since a number is replaced, it means that at first, a number will be deleted, and in its place, a new number will be added. That is a combination of type 1 and type 2, discussed above.

Let's consider an example based on the above situation. 

Example 1

From a set of 5 numbers with an average of 13, one number is replaced. The average is increased by 4. The outgoing number is 32, then find the replaced number.

Solution 1

In such questions, it is essential to note that after the replacement, if the average increases, then the number added will be greater than the number removed, and vice versa. There are no hard facts; you may figure it out by trying a few questions and observing the pattern.

Original sum of 5 numbers without any replacement  = ( 5 * 13 ) = 65

The number removed is 32 and the number inserted is, let's say, x.

Sum of 5 numbers after the replacement = ( 5 * 17) = 85.

Note -  We have taken an average of 17 as given in the question, the average increases by 4.

Clearly, the original sum of 5 numbers without any replacement minus the outgoing number will equal the sum of four numbers.

Sum of four numbers = 65 - 32 = 33.

In the sum of five numbers after the replacement, four numbers will be the same as taking in the original average, and the fifth number will be the incoming number.

Sum of five numbers after the replacement =  sum of four numbers + incoming number

85 = 33 + x

x = 85 - 33 = 52

Hence, the incoming number is 52.


Let's take another example wherein the average will decrease after replacing a number.

Example 2

From a set of 5 numbers with an average of 13, one number is replaced. The average is decreased by 4. The outgoing number is 32, then find the replaced number.

Solution 2

The sum of original numbers = 5 * 13 = 65

Sum of numbers after the replacement = 5 * 9 = 45. 
Note that it is given that the average decreases by 4.

Outgoing number = 32

Incoming number = x


In the sum of five numbers after the replacement, four numbers will be the same as taking in the original average, and the fifth number will be the incoming number.

Sum of four numbers = Sum of five numbers before replacement - Outgoing number
                                        = 65 - 32
                                        = 33

Sum of five numbers after replacement = Sum of four numbers + Incoming Number

45 = 33 + x
  x = 12

Hence, the replaced number is 12.

Concept of Weighted Average

The weighted average is a method that takes into account the relative importance of the numbers in data collection. Before the final calculation of a weighted average, each value in the data set is multiplied by a predefined weight.

It's used in cases where some factors' relative importance or frequency need to be taken care of. For example, Suppose you're conducting a survey where you want responses from all the classes of a school. It is possible that you get fewer responses from some classes compared to others. To represent everyone's response proportionately, you can weigh the responses from each class.


Considering that there are k groups with averages A1, A2, … Ak and having n1, n2, … nk elements, then the weighted average is given by the formula:

Weighted Average

FORMULA

Aw

n1A1 + n2A2 + n3A3 + … + nkAk / n1 + n2 + n3 + … + nk

Let us consider an example of a weighted average.

Example 1

Suppose you purchase rice at prices ₹30 per kg and ₹70 per kg in the ratio of 2:3. What is the average price of rice?

Solution 1

Average price = (n1A1 + n2A2) / (n1+n2) [ A1= 30, A2 = 70, n1 = 2, n2 = 3 ]

Average price = (2× 30+3×70) / (2 + 3) 
                         = 270/5 
                         = ₹54 per kg

Example 2

Let's say you invest ₹2L and get a 30% return. An investment of ₹3L gets a 70% return. What is the average % return?

Solution 2

Average% return = (n1A1 +n2A2) / (n1+n2)  [ A1 = 30%, A2 = 70%, n1 = 2L, and n2 = 3L ].

Average% return = (2× 30+3×70) / (2 + 3) 
                               = 270/5 
                               = 54 %.


Check out this problem - Subarray Sum Divisible By K
 
Let us now answer some frequently asked questions.

Frequently Asked Questions

What is average?

Average can be defined as a number that measures the central tendency of a group of numbers. In other words, it estimates where the center point of the set of numbers lies. 

What is the weighted average?

The weighted average is a calculation considering a data set's varied levels of significance. A specified weight is multiplied by each value in the data set before the final computation is completed when calculating a weighted average.

How do you calculate the average?

The average or mean is computed by adding a set of integers and then dividing it by the count of those numbers.

Do average and sum mean the same thing?

No, the average is a number that measures the central tendency of a collection of numbers. On the other hand, the sum is obtained by adding the numbers.

What is the use of averages?

You can use the concept of averages to compare different quantities of the same type.

Conclusion

This blog discussed how to find averages in detail. We have discussed all the approaches to calculating averages. We also saw some common types of questions asked on averages.

You can refer to these articles to prepare for competitive exams.


You may refer to our Guided Path on Code Studios for enhancing your skill set on DSACompetitive ProgrammingSystem Design, etc. Check out essential interview questions, practice our available mock tests, look at the interview bundle for interview preparation, and so much more!

Happy Learning, Ninjas!

Previous article
Ratio and Proportions
Next article
Percentages
Live masterclass