The unstable formula theorem revisited via algorithms