In: Computer Science
Question: State if an algorithm (satisfying the formal definition of an algorithm) which is guaranteed to find a solution exists or not for each of the following problems by filling the blanks with “Yes” (an algorithm guaranteed to find a solution exists) or “No” (an algorithm guaranteed to find a solution does not exist).
1. Finding the average height of a person in a group, given the height of each person in the group
2. Finding all factors of a finite integer
3. Finding if a triangle is scalene or not, when the coordinates of its vertices are given
4. Finding a path from the given start location to the given goal location in a finite maze (the number of junctions is finite and the length of path connecting any two junctions is also finite) that changes unpredictably at any time
SOLUTION:
Yes - an algorithm guaranteed to find a solution exists
No - an algorithm guaranteed to find a solution does not exist
1. Finding the average height of a person in a group, given the height of each person in the group
YES
Average height = Sum of all heights / number of people in the group
Using the above formula in an algorithm, the solution to the question exists
2. Finding all factors of a finite integer
YES
Using the below algorithm, the solution to the question exists
Loop from i=1 to i<=n //n is the finite integer
if ( n modulus i = =0)
then “i is factor of n”
3. Finding if a triangle is scalene or not, when the coordinates of its vertices are given
YES
Using the below algorithm, the solution to the question exists
//ABC is the triangle whose coordinates of vertices are given
Calculate distance between AB
Calculate distance between BC
Calculate distance between CA
if( AB != BC and BC != CA)
then “Given triangle is Scalene triangle”
4. Finding a path from the given start location to the given goal location in a finite maze (the number of junctions is finite and the length of path connecting any two junctions is also finite) that changes unpredictably at any time
NO
There exists no algorithm which can guarantee a solution to the question, because the maze changes unpredictably at any time.
*****************************************************************
Please comment for any further help on this question.