Pregunta de entrevista de Amazon

How does grep work internally?