If X is a stand-in for an actual, named algorithm, then X Algorithm is usually the correct construction. For example:
- The A* algorithm
- The DFS shortest path algorithm
- Kruskal's Algorithm
The wikipedia page you cite isn't using "Algorithm A" to mean the same thing as "A* algorithm." It's using "Algorithm A" as shorthand for "Any algorithm, which we will refer to as A." Likewise, it describes "Problem P." P isn't some special problem, it's a stand in for an arbitrary problem that we are using A to solve.
To put it in terms of integers:
4 is an integer. (Just like A* is an algorithm)
Let integer i be an integer less than 5. i could be 4, or it could be 1, 2, 3, or -8. It's not necessarily 4. integer i is analogous to algorithm A.
The variable X vs the X variable
I suspect there isn't an actual grammatical rule here, and it's entirely dependent on what field you're in, or who you're talking to. I personally hear all of these on a fairly regular basis and would never misunderstand.
I would bet, though, that a phrase like "the x variable" is more likely to be used in the context of describing a cartesian plane. "The x variable" can be used as a property of the graph rather than a specific thing with a specific value.
"The variable X" is more likely to be used when talking about a literal variable in a snippet of code called X. Just like one might say "the dog Spot" (there is a dog and its name is Spot), the thing you're talking about is a variable, and its name is X.
With that said, if you're writing for a specific journal or at a certain instutution they might have an explicit style guide. Otherwise you're probably in the clear and the audience will understand perfectly well.