What algorithm does YouTube follow to convert between different formats? Does YouTube store different videos (for different formats) on disk or store only 1 and convert from this to appropriate format as requested?
Youtube stores whatever you upload and transcodes to other formats using their own versions of multiple compression formats including h.264 and webm. All transcodes go from the same original file that you upload and are stored after transcoding. Youtube may change the options used from time to time and save new encodes of the video. Encodes are generally pre-rendered upon upload and then used from disk as far as I can tell.