Implementation of the A* Search algorithm