[verb (plain)] + の [i-adj] + の [na-adj] + な + の [noun] + な + の
の after a verb or an adjective turns the phrase into a noun, so it can take は, が or を: "running", "eating", "studying". A verb or い-adjective takes の in the plain form, past or present; a な-adjective takes な.
The phrase before の can have its own subject, marked with が: かれ彼がうたう歌うのをきいた聞いた, "I heard him sing".
With verbs of seeing and hearing, and with まつ待つ and てつだう手伝う, only の works, because you see, hear or wait for the action as it happens.
Before です, only こと works.
A の that ends a sentence is the casual form of のです: it asks for or gives an explanation. That is a separate grammar point.