7.16Melody can tell you what kind of cadence is possible
If the final melody note is C in C major:
good candidate for tonic.
If the melody ends on B:
that might suggest unresolved tension.
If it ends on G:
it could still be over C, because G is the fifth of C.
So melody ending on 5 can still feel complete harmonically.
Do not assume melody must end on tonic to resolve.