The correct option is
D Algorithm 2
Let us consider Algorithm 1:
Values of x |
Value of y |
3 |
15 |
4 |
19 |
5 |
23 |
Consider any two coordinates, say (3,15) and (4,19)
Slope=Change in yChange in x=19 − 154 − 3
⇒ Slope = 4
Equation of straight line is y = mx + c
Putting the value of m, we get:
y=4x+c
Consider one point, say (3,15)
Substituting the values, we get:
⇒15=4(3)+c
⇒15=12+c
⇒3=c
Therefore, the equation for Algorithm 1 will be y = 4x + 3
At x = 0,
y=4×0+3 ⇒ y = 3
Therefore, at zero input the output is 3. So it is not the correct option.
Let us consider Algorithm 2:
Value of x |
Value of y |
3 |
13.5 |
4 |
18 |
5 |
22.5 |
Consider any two coordinates, say (3,13.5) and (4,18)
Slope=Change in yChange in x=18 − 13.54 − 3
⇒ Slope = 4.5
Equation of straight line is y = mx + c
Putting the value of m, we get:
y=4.5x+c
Consider one point, say (5,22.5)
Substituting the values, we get:
⇒22.5=4.5(5)+c
⇒22.5=22.5+c
⇒0=c
Therefore, the equation for Algorithm 2 will be y = 4.x + 3
At x = 0,
y=4×0+0 ⇒ y = 0
Therefore, at zero input the output is zero. So it is correct option.