Which class of algorithms would this sort of a problem belong to? If I had to pick up a book on algorithms, which topic should I be looking at to find more problems of this nature and their explanation?

Given the current location on of the horse (or whatever the thing is that moves two spaces horizontally and one vertically) on a chess board, say, (x1, y1), how many steps would you need to move it to reach a destination location (x2, y2)?

  • 1
    You should better ask which class of algorihm can solve this problem. Usually a problem can be solved by different classes of algorothms. Aug 14, 2016 at 9:06
  • That chess piece is called a Knight.
    – Sjoerd
    Aug 14, 2016 at 16:59

1 Answer 1


This would be a pathfinding algorithm which would be part of graph theory.

Example algorithms include A* and Dijkstra's algorithm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.