3

I have two algorithms $P, Q$ for solving the same problem (a decision problem on sequences in $R^n$) and I want to decide if they differ in any meaningful way. The following describes the constraints:

  • $P,Q$ always halt on a defined, finite set of inputs $S \subset R^n$ and provide the same output (they compute the same function).
  • For all inputs $s \in S$, both $P,Q$ perform the same operations.
  • For all inputs $s \in S$, both $P,Q$ perform the same number of operations.
  • For all inputs $s \in S$, both $P,Q$ use the same amount of memory.

For me (someone who doesn't have a background in algorithms), this seems like a reasonable notion of equality between $P,Q$ over $S$. Are there cases of two algorithms that satisfy these constraints yet differ in some meaningful way?

1 Answers1

6

This question is outside the realm of "ordinary" algorithm analysis and complexity theory. Of course this doesn't mean that questions like yours can't be interesting and people might study them. However, I don't think your criteria are great at distinguishing between algorithms. Most models of computation have a relatively small set of instructions, and complex algorithms likely utilize all of them, so your first criteria contains very little information. Another issue is that your criteria can be fooled by simple tricks. For example say $P$ and $Q$ are algorithms, $P$ performs fewer operations than $Q$, and they both use the same amount of memory. Suppose we make $P'$ an algorithm that performs $P$ and then does a number of useless operations so that it performs the same total number of operations as $Q$. Your criteria state that $P'$ and $Q$ equivalent.

Of course, number of operations (running time) and amount of memory used are good metrics to evaluate and compare algorithms, which is what we do in algorithm analysis. However, they are not enough to capture the semantics/logic of the algorithm.

NaturalLogZ
  • 991
  • 5
  • 11