How do I know if my algorithm is right (without coding)?
You prove that the algorithm is correct.  This requires (1) writing out a precise specification of what you mean by correctness, (2) writing a mathematical proof that your algorithm meets this specification.  Algorithms courses and textbooks often include some material on how to prove algorithms correct, as well as many examples of this, so that would be a good starting point to study, if you want to learn more about proofs of correctness for algorithms.  See also formal methods / formal verification, and possibly the following question on this site: How to fool the &quot;try some test cases&quot; heuristic: Algorithms that appear correct, but are actually incorrect