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 a path from the given start location to the given goal location in an infinite maze (the number of roads intersecting at one or more junctions is infinite, but the length of path connecting any two junctions is finite)
2. Finding the area of a pentagon when the coordinates of all of its vertices are given
3. Finding the perimeter of a hexagon when the coordinates of its vertices are given
4. Finding an estimate of average daily snowfall in winter for a city, given the snowfall data for all days in the last five winters
Dear learner,
Here is the solution to your question
1. 'No'. Since the domain space for the algorithm to work upon is infinite, it won't be able to return any answer (or it cannot 'guarantee' to return an answer). Infinite domain space makes the algorithm to go in an infinite loop since there is no end (or 'stopping') point for it. If the question were to find least distance, the answer could have been different as after a certain point if the distance doesn't reduce we can assume that we have found the solution and stop. Since the question if to find a path we can NOT guarantee a solution.
2. 'Yes'. The area of pentagon can be calculated given the coordinates of the vertices with the help of 'Shoelace formula'.
Shoelace formula is a generalized formula where you can find area any of n-sided polygon given the vertices by

Basic algorithm for pentagon will be as follows
set j = 5 - 1 //v is the vertices
for i = 0; i < 5; i++
{ area = area + (X[j] + X[i]) * (Y[j] - Y[i]) //X[i] and [Y[i] are the x and y coordinates of ith vertice
j = i // j is previous vertex to i
}
3. 'Yes'. The perimeter of a hexagon can be answered by an algorithm given the coordinates. We have to find the euclidean distance between the ordered vertices so that we can have length of all 6 sides, the sum of which will be the perimeter.
The euclidean distance is given by,

The basic algorithm for hexagon can be as follows
perimeter = dist(v[1],v[2]) + dist(v[2],v[3]) + dist(v[3],v[4]) + dist(v[4],v[5]) + dist(v[5],v[6]) + dist(v[6],v[1]) // where v[i] holds the coordinates of ith vertice.
4.'Yes'. Although it may seem an impossible task, weather prediction is nowadays quite easy if you have previous data. Since the average daily snowfall is a continuous variable (and not discrete), the algorithm to be used here is called as linear regression (one of the machine learning models). Linear Regression, basically tries creates a line fitting all the previous years' data and hence extending it for the coming years, we can roughly estimate the average snowfall of the coming year.
I hope I have explained the question the way you were expecting. If you still have any doubts or want any further explanation, feel free to ask us in the comments.
Please leave a like if this was helpful.
Thanks,
Happy Studying.
Question: State if an algorithm (satisfying the formal definition of an algorithm) which is guaranteed to...
The Problem A robot is asked to navigate a maze. It is placed at a certain position (the starting position) in the maze and is asked to try to reach another position (the goal position). Positions in the maze will either be open or blocked with an obstacle. Positions are identified by (x,y) coordinates. At any given moment, the robot can only move 1 step in one of 4 directions. Valid moves are: ● Go North: (x,y) -> (x,y-1) ●...
What is the role of polymorphism? Question options: Polymorphism allows a programmer to manipulate objects that share a set of tasks, even though the tasks are executed in different ways. Polymorphism allows a programmer to use a subclass object in place of a superclass object. Polymorphism allows a subclass to override a superclass method by providing a completely new implementation. Polymorphism allows a subclass to extend a superclass method by performing the superclass task plus some additional work. Assume that...