Docking in c# with x and y parameter...

May 27 2013 5:23 AM


Problem Statement: - This problem is about finding a shortest distance between two points. Ask
user to enter a number N. Then you have to create a space with NxN dimensions. User then will
enter coordinates for two points in this NxN space and you have to find the minimum number of
steps you need to get from one point to another. The steps are always unit steps. Your program
should output the number of steps needed and also sequence of steps required for one of the
possible shortest path.
An Example: - Suppose that user enters N as 2, then you have a 2-dimensional space as shown in
the figure below.
Now if user enters two points as (2,2) and (4,4) then taking one unit step at a time, one possible
solution is shown in the figure. So the output showing the sequence of steps is (4,4) to (4,3), (4,3) to
(4,2), (4,2,) to (3,2), (3,2) to (2,2). Which are 4 steps in total. The same thing can be done for 3-
dimensional and can be extended to N-dimensions.

Answers (1)