Discover the answers you need at Westonci.ca, where experts provide clear and concise information on various topics. Discover comprehensive solutions to your questions from a wide network of experts on our user-friendly platform. Our platform provides a seamless experience for finding reliable answers from a network of experienced professionals.

Assume that an O(log2N) algorithm runs for 10 milliseconds when the input size (N) is 32. What input size makes the algorithm run for 14 milliseconds

Sagot :

Answer:

An input size of N = 128 makes the algorithm run for 14 milliseconds

Explanation:

O(log2N)

This means that the running time for an algorithm of length N is given by:

[tex]F(N) = c\log_{2}{N}[/tex]

In which C is a constant.

Runs for 10 milliseconds when the input size (N) is 32.

This means that [tex]F(32) = 10[/tex]

So

[tex]F(N) = c\log_{2}{N}[/tex]

[tex]10 = c\log_{2}{32}[/tex]

Since [tex]2^5 = 32, \log_{2}{32} = 5[/tex]

Then

[tex]5c = 10[/tex]

[tex]c = \frac{10}{5}[/tex]

[tex]c = 2[/tex]

Thus:

[tex]F(N) = 2\log_{2}{N}[/tex]

What input size makes the algorithm run for 14 milliseconds

N for which [tex]F(N) = 14[/tex]. So

[tex]F(N) = 2\log_{2}{N}[/tex]

[tex]14 = 2\log_{2}{N}[/tex]

[tex]\log_{2}{N} = 7[/tex]

[tex]2^{\log_{2}{N}} = 2^7[/tex]

[tex]N = 128[/tex]

An input size of N = 128 makes the algorithm run for 14 milliseconds