2

Order of operation in each recursive step of a backtracking algorithms are how much important in terms of the efficiency of that particular algorithm?

For Ex.

In the Knight’s Tour problem.

The knight is placed on the first block of an empty board and, moving according to the rules of chess, must visit each square exactly once.

In each step there are 8 possible (in general) ways to move.

int xMove[8] = {  2, 1, -1, -2, -2, -1,  1,  2 };
int yMove[8] = {  1, 2,  2,  1, -1, -2, -2, -1 };

If I change this order like...

int xmove[8] = {  -2, -2, 2, 2, -1, -1,  1,  1};
int ymove[8] = {  -1,  1,-1, 1, -2,  2, -2,  2};

Now, for a n*n board upto n=6 both the operation order does not affect any visible change in the execution time,

But if it is n >= 7

First operation (movement) order's execution time is much less than the later one. In such cases, it is not feasible to generate all the O(m!) operation order and test the algorithm. So how do I determine the performance of such algorithms on a specific movement order, or rather how could it be possible to reach one (or a set) of operation orders such that the algorithm that is more efficient in terms of execution time.

false
  • 10,264
  • 13
  • 101
  • 209
sb15
  • 313
  • 5
  • 18

1 Answers1

1

This is an interesting problem from a Math/CS perspective. There definitely exists a permutation (or set of permutations) that would be most efficient for a given n . I don't know if there is a permutation that is most efficient among all n. I would guess not. There could be a permutation that is better 'on average' (however you define that) across all n.

If I was tasked to find an efficient permutation I might try doing the following: I would generate a fixed number x of randomly generated move orders. Measure their efficiency. For every one of the randomly generated movesets, randomly create a fixed number of permutations that are near the original. Compute their efficiencies. Now you have many more permutations than you started with. Take top x performing ones and repeat. This will provide some locally maxed algorithms, but I don't know if it leads up to the globally maxed algorithm(s).

Carlos Bribiescas
  • 4,197
  • 9
  • 35
  • 66
  • sounds like you've got selection and inheritance, now you just need mutation and crossover to have a Genetic Algorithm. As you've hinted, these types of algorithms tend to find local maxima. – thebjorn Aug 07 '15 at 22:02