As you already mentioned it, you have a really pratical option to handle your conflict. The acknowledgement section in which you can also wrap authors's contribution in most journals. In case you decide to offer him the co-authorship you can and should put all author's contribution as they have happened. Your own case is pretty clear here. AB contributed by developing and implementing the algorithm as well as writing the complete draft.
I would like to give you the following points you might have missed considering yet regarding other co-authors, especially your professor's one:
Is your professor the project leader? You could acknowledge his contribution by stating this, but also you could consider granting him co-authorship. Is this a collaborative project which you are provided with initially? Your professor most likely has spent a lot of years operating in his position within the science field to have the capability to do so. He can be protecting you from an overwehlming administrative amount of work (which is needed for the existense of positions like yours). Without him there would be no workstation, no access to a free cluster to perform heavy computations?
For me this are ethical reasons (or others like this examplary given exists behind the scenes) to grant a co-authorship if clarified with something like "Prof. XY's contribution gets acknowledged with leadership of project XZ funded under nummer 111 by YZ" All co-authors in addition contributed by an internal review. "All co-authors" needs to be addapted in your considered two-author case.
Take some weeks to consider these points in case you never done this before. Talk to your collagues about it. Also to some long term post-docs. Those can help you seeing stuff faster which now might still be hidden to you. I also would like to emphasize. You never put just someone as a co-author, you offer him co-authorship. It is a much more respectful way to describe this procedere because this forumlation still implies the possibility that your professor rejects because he consideres his time he is able to spent not worthy to accept.
Finally, I just gave you my point of view, but I cannot give you a direct answer. Consider such points and also the arguments from a contradictionary point of view which might show up in another answer. It will still be your decision which you have to do by yourself.
There is authors guidelines in every journal which you should read carefully and follow. I have not done this in your field (the reading of the guidelines). I know though some papers of computer science and those have a (for my field) rather uncommon high frequency of really small teams or single authors. So the ethical common sense might be shifted a bit from my pov. My main point was that I see no ethical conflict if the pure secondary nature of contribution is stated clearly (but ofc in agreement with the journal).