This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs) focuses on “Line Point Distance”.
1. The shortest distance between a line and a point is achieved when?
a) a line is drawn at 90 degrees to the given line from the given point
b) a line is drawn at 180 degrees to the given line from the given point
c) a line is drawn at 60 degrees to the given line from the given point
d) a line is drawn at 270 degrees to the given line from the given point
View Answer
Explanation: The shortest distance between a line and a point is achieved when a line is drawn at 90 degrees to the given line from the given point.
2. What is the shortest distance between the line given by ax + by + c = 0 and the point (x1,y1)?
a)
b)
c)
d) ax1+by1+c
View Answer
Explanation: The shortest distance between a line and a point is given by the formula (ax1+by1+c)/(√a2+b2). This formula can be derived using the formula of area of a triangle.
3. What is the shortest distance between the line given by -2x + 3y + 4 = 0 and the point (5,6)?
a) 4.5 units
b) 5.4 units
c) 4.3 units
d) 3.3 units
View Answer
Explanation: The shortest distance between a line and a point is given by the formula (ax1+by1+c)/(√a2+b2). Using this formula we get the answer 3.3 units.
4. What is the general formula for finding the shortest distance between two parallel lines given by ax+by+c1=0 and ax+by+c2=0?
a)
b)
c)
d) c1+c2
View Answer
Explanation: The general formula for finding the shortest distance between two parallel lines given by ax+by+c1 and ax+by+c2 is (c1-c2)/(√a2+b2). We can find this by considering the distance of any one point on one of the line to the other line.
5. What is the distance between the lines 3x-4y+7=0 and 3x-4y+5=0?
a) 1 unit
b) 0.5 unit
c) 0.8 unit
d) 0.4 unit
View Answer
Explanation: As the given lines are parallel so the distance between them can be calculated by using the formula (c1-c2)/(√a2+b2). So we get the distance as 0.4 unit.
6. What will be the slope of the line given by ax + by + c = 0?
a) -a/b
b) -b/a
c) -c/a
d) a/c
View Answer
Explanation: The slope of a line given by the equation ax + by + c=0 has the slope of -a/b. So two lines having the same ratio of the coefficient of x and y will be parallel to each other.
7. What will be the slope of the line given by 10x + 5y + 8=0?
a) -5
b) -2
c) -1.25
d) 5
View Answer
Explanation: The slope of a line given by the equation ax + by + c=0 has the slope of -a/b. So the slope of the given line will be -2.
8. What will be the co-ordinates of foot of perpendicular line drawn from the point (-1,3) to the line 3x-4y-16=0?
a) (1/5,2/5)
b) (2/25,5/25)
c) (68/25,-49/25)
d) (-49/25,68/25)
View Answer
Explanation: The foot of perpendicular can be found by equating the distance between the two points and the distance between point and line. This is found to be (68/25,-49/25).
9. Which of the following is used to find the absolute value of the argument in C++?
a) abs()
b) fabs()
c) mod()
d) ab()
View Answer
Explanation: In C++ the absolute value of an argument can be found by using the function fabs(). It is available under the header file math.h.
10. What will be the slope of the line perpendicular to the line 6x-3y-16=0?
a) 1/2
b) -1/2
c) 2
d) -2
View Answer
Explanation: For two lines to be perpendicular the product of their slopes should be equal to -1. So as the slope of given line is 2 so the slope of line perpendicular to it will be -1/2.
11. Find the output of the following code.
#include<math.h> #include<iostream> using namespace std; void distance(float x, float y, float a, float b, float c) { float d = fabs((a * x + b * y + c)) / (sqrt(a * a + b * b)); cout<<d; return; } int main() { float x = -2; float y = -3; float a = 5; float b = -2; float c = - 4; distance(x, y, a, b, c); return 0; }
a) 2.8
b) 1.8
c) 1.4
d) 2.4
View Answer
Explanation: The given code calculates the shortest distance between line and a point. So the output will be 1.4.
Sanfoundry Global Education & Learning Series – Data Structures & Algorithms.
To practice all areas of Data Structures & Algorithms, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Practice Programming MCQs
- Apply for Computer Science Internship
- Check Programming Books
- Practice Data Structure MCQ
- Check Design and Analysis of Algorithms Books