Explore Westonci.ca, the top Q&A platform where your questions are answered by professionals and enthusiasts alike. Join our Q&A platform to connect with experts dedicated to providing precise answers to your questions in different areas. Our platform offers a seamless experience for finding reliable answers from a network of knowledgeable 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