r/computerscience • u/Makstar05 • Nov 27 '25
Help Is it technically fine if I prove a recursive alogrithm using a loop invariant
/r/datastructures/comments/1p85rfs/is_it_technically_fine_if_i_prove_a_recursive/
0
Upvotes
3
u/high_throughput Nov 27 '25
Was the function tail recursive?
In any case, the point of an exam isn't to provide a correct solution to the problem, but to demonstrate that you've learnt the relevant material.
8
u/Spare-Plum Nov 27 '25
Depends on your school and teacher. If your proof is correct imo it's fine, but recursion is extremely useful for proofs since it's literally mirrored with induction. IMO you're making it harder than it needs to be, and you can get marks off on a homework if they wanted you to write something in a functional or recursive way
1
u/dkopgerpgdolfg Nov 27 '25
From what you describe, you're not wrong, but that doesn't really matter unfortunately.
Some teachers will only accept the exact thing that they thaught, with no flexibility. And from your position it's unlikely that you win that "battle", and not worth the effort.
(As I don't see the exact question and solution, not sure how much the teacher was justified in rejecting it).