Dictionary in memory

Report a typo

Let's imagine you have created an online translator program. This program takes an English paragraph as input and translates the whole paragraph word by word to any desired language. So, your program has to fetch each word's translation from your server. But your online server has an inferior performance for some reason. It takes around one second to translate one word.

To overcome this issue, you would like to use your memoization knowledge. Indeed, some words appear multiple times in a paragraph. So you have changed your program to remember each translation fetched from the server. If the same word appears again in a paragraph, your program instantly translates the word using its stored data, rather than fetching the translation from the server.

Here is a line from the "Star Wars Episode I: The Phantom Menace": Fear leads to anger; anger leads to hatred; hatred leads to conflict; conflict leads to suffering.

How much time in seconds would your program take to translate the sentence without and with memoization?

Please write your answer in the following format: 20,1220, 12

Enter a short text
___

Create a free account to access the full topic