7.8k views
2 votes
int) You are the head of a division of a big Silicon Valley company and have assigned one of your engineers, Jim, the job of devising an algorithm to sort through an English text of n words and convert it into an Esperanto document. Jim comes up with an algorithm which takes 2n2+2n bit operations to handle an input text with n words. Suppose the computers in your business can handle one bit operation every nanosecond (1 nanosecond =10−9 seconds). How many nanoseconds would it take Jim's algorithm to convert a text with 10 wor

User Jazza
by
5.1k points

1 Answer

4 votes

Answer:

Correct option is E

Step-by-step explanation:

a) 2n^2+2^n operations are required for a text with n words

Thus, number of operations for a text with n=10 words is 2\cdot 10^2+2^{10}=1224 operation

Each operation takes one nanosecond, so we need 1224 nanoseconds for Jim's algorithm

b) If n=50, number of operations required is 2\cdot 50^2+2^{50}\approx 1.12589990681\times 10^{15}

To amount of times required is 1.12589990681\times 10^{15} nanoseconds which is

1125899.90685 seconds (we divided by 10^{9}

As 1$day$=24$hours$=24\times 60$minutes$=24\times 60\times 60$seconds$

The time in seconds, our algortihm runs is \frac{1125899.90685}{24\cdot 60\cdot 60}=13.0312 days

Number of days is {\color{Red} 13.0312}

c) In this case, computing order of number of years is more important than number of years itself

We note that n=100 so that 2(100)^2+2^{100}\approx 1.267650600210\times 10^{30} operation (=time in nanosecond)

Which is 1.267650600210\times 10^{21} seconds

So that the time required is 1.4671881947\times 10^{16} days

Each year comprises of 365 days so the number of years it takes is

\frac{1.4671881947\times 10^{16}}{365}=4.0197\times 10^{13} years

That is, 40.197\times 10^{12}=$Slightly more than $40$ trillion years$

User FootsieNG
by
4.7k points