Posts Tagged ‘absolute value’

Differences between a definition and an algorithm?

April 2, 2016

I am hoping that you can shed some light on the differences between a definition and an algorithm.

Let’s take an example. Consider the “absolute value” that you learned in elementary school. Is the following a definition of absolute value, or is it an algorithm for computing the absolute value?

|x| = (if x < 0 then –x else x)

If it’s a definition, what would an algorithm look like?

If it’s an algorithm, what would a definition look like?