Pregunta de entrevista

Entrevista de Software Development Manager

-

Google

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

Respuesta

Respuestas de entrevistas

3 respuestas

12

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

Jewel en

1

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

8

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.