Pregunta de entrevista

Entrevista de Software Development Manager



Given a large unsorted text file containing thousands of words count the number of times each word appears.


Respuestas de entrevistas

3 respuestas


How about building a prefix tree and keep the frequency at the leaf of the tree?

Jewel en


Of course having a hashmap or an associative array would be a naive way. They are looking for optimization. Probably either using a hashmap but in a multithreaded way or having a more optimized algorithm that involves uncommon data structures

Interviewee en


I answered that I would build a hash map where the key was each word encountered and the "value" was the number of times that word was encountered. O(n) complexity.

Anónimo en

Añadir respuestas o comentarios

Para publicar un comentario sobre esto, inicia sesión o regístrate.