In general, "the" is used to indicate a specific example that has already been introduced or that the reader will recognize. You would say the algorithm if you have previously described it in the text, or if there is only one algorithm that would apply to that situation and the reader would know what it is.
For example, I could say I used the bubble-sort algorithm (to sort something) because there is only one of this kind of sorting algorithm. Or, if I'd already talked extensively about the bubble-sort, then I would continue to refer to it as the algorithm.
Otherwise, if I wasn't sure whether the the reader was already familiar with the bubble-sort, I might instead say I used a bubble-sort algorithm, and then explain that there's really only one of them. After that I'd refer to it as the algorithm.
So your question depends on context -- what have you previously said about your algorithm? If you've already described it, then you would use the algorithm. If you haven't yet introduced it, and if there is more than one algorithm to calculate the dimensions of a structure, you would use an algorithm.
The liver is located on the right side of the body, immediately below the diaphragm and adjacent to the stomach.
In the human body there's only one liver, one diaphragm, and one stomach, so the reader should know which organs we mean.
On the way home from school, the boys found a book lying in the street. But when they looked through it, they found the book was completely blank.
At first it's just any book, but after the reader should infer that, "the book," means, "the book the boys found".
Mr. Stark called to his butler, "Jarvis, could you bring the Rolls around? I feel like taking a drive this morning."
Mr. Stark assumes his butler knows which Rolls-Royce car he wants -- either there is only one, or there is one he prefers. However since he hasn't specified where he plans to drive, at this point it's just "a drive".
The drive from the house to the country club took Mr. Stark forty minutes.
Now that we've specified where Mr. Stark is going, "the drive" is appropriate. Also we assume the reader knows (or can infer) which house and which country club we mean.
A background process collects statistics on usage patterns. All the statistical data is stored in a relational database.
We haven't previously talked about the process so it's "a background process". Since we mention the data in the first sentence, in the second sentence we can say "the statistical data". Since we haven't specified which database, it's "a relational database".