Algorithms cannot be copyrighted. What is copyrighted is the creative expression of an algorithm. The variable names, the comments, choosing a for loop vs a while loop, or a ternary operator over an “if”, the order of arguments to a function, architectural decisions, etc.
Copyright is formed when a human makes a choice about equivalent ways of implementing an algorithm.
Is there a jurisdiction that allows purely algorithms to be copyrighted? As far as I know, usually algorithms come under the umbrella of patents (in jurisdictions that allow software patents) rather than copyright.
For example, it would interfere with e.g. copyright of scientific/mathematical papers if algorithms were copyrightable, as mathematicians would not be able to extend another mathematician’s ideas without first gaining permission.
Copyright is formed when a human makes a choice about equivalent ways of implementing an algorithm.