Question

How do you know an equation has a log (n) algorithm performance? I can't seem to...

How do you know an equation has a log (n) algorithm performance? I can't seem to understand how you know it is log(n) compute time

Homework Answers

Answer #1

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

Let us take the very basic case.

For example equation is

T(n)=T(n/2)+1

So, basically it can be rewritten as

T(n)=T(n/2^2)+1+1

...

..

T(n)=T(n/2^k)+1*k

So, since the base case is T(1)

n should be 2^k

So,

Take logs on both sides

2^k=n

k=log2(n)

So,

T(n)=T(1)+log2(n)

And since the T(1) is constant and higher term in power of n is log2(n)

So, it is O(log(n))

Kindly revert for any queries

Thanks.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
I just can't seem to understand statistics. I ave a total of 182,094, a mean of...
I just can't seem to understand statistics. I ave a total of 182,094, a mean of 3,570 a median of 2,482, a minimum of 306, a max of 17,680 and a standard deviation of 3,628.68 , and a sample size of 52 I need to know how to do the following. ·      1. Determine if there is sufficient evidence to conclude the average amount of marriages is greater or equal to 7000 in the United States and territories at the .10...
2. Design a deterministic algorithm to solve the following problem. input: An array A[1...n] of n...
2. Design a deterministic algorithm to solve the following problem. input: An array A[1...n] of n integers. output: Two different indices i and j such that A[i] = A[j], if such indices exist. Otherwise, return NONE. Your algorithm must take O(n log(n)) time. You must describe your algorithm in plain English (no pseudocode) and you must explain why the running time of your algorithm is O(n log(n)).
I know this is a silly question, but I'm only asking this because I honestly can't...
I know this is a silly question, but I'm only asking this because I honestly can't seem to find a good definition of time that doesn't include another word that relies on the definition (or logical understanding rather) of time. For example, in many dictionaries the definition of time is as follows: Time is a measure in which events can be ordered from the past through the present into the future, and also the measure of durations of events and...
NOTE:: *On a- I need to know HOW you get -10 within the equation! - If...
NOTE:: *On a- I need to know HOW you get -10 within the equation! - If you are not going to explain this please do not answer this question. The equation for a demand curve has been estimated to be Q=100 - 10P + 0.5Y Where Q is quantity, P is price, and Y is income. Assume P=7 and Y=50. A) At a price of 7, what is price elasticity? B) At an income level of 50, what is income...
Consider the following algorithm. i ← 2 while (N mod i) ≠ 0 do i ←...
Consider the following algorithm. i ← 2 while (N mod i) ≠ 0 do i ← i + 1 Suppose instead that N is in {2, 3, 4, 5, 6, 7, 8, 9}, and all these values are equally likely. Find the average-case number of "N mod i" operations made by this algorithm.
How do you calculate an equilibrium constant for n-propyl alcohol and acetic acid? I really need...
How do you calculate an equilibrium constant for n-propyl alcohol and acetic acid? I really need the step by step so that I can understand this. Thanks in advance and if you need further information for this please let me know I and I can get it.
Objective function in Local Search , I don't seem to understand how to formulate it ....
Objective function in Local Search , I don't seem to understand how to formulate it . do i just write how i found the local\global minimum ?
I know this has been answered before but I do NOT understand. Can you explain it...
I know this has been answered before but I do NOT understand. Can you explain it better? We know n=900 and p-hat is .13, and 97.5 % confidence interval. An explanation would be appreciated for a beginner. According to a survey with 900 males, 13% are left-handed. Construct a 97.5% confidence interval for the population proportion of all males who are left-handed. [3 marks] If both the sample size and the number of successes are doubled, what is the effect...
Design a recursive divide-and-conquer algorithm A(n) that takes an integer input n ≥ 0, and returns...
Design a recursive divide-and-conquer algorithm A(n) that takes an integer input n ≥ 0, and returns the total number of 1’s in n’s binary representation. Note that the input is n, not its binary representation. For example, A(9) should return 2 as 9’s binary representation is 1001, while A(7) should return 3 since 7 is 111 in binary. Note that your algorithm should have a running time of O(log n). Justify your answer. You need to do the following: (1)...
1. Given an n-element array A, Algorithm X executes an O(n)-time computation for each even number...
1. Given an n-element array A, Algorithm X executes an O(n)-time computation for each even number in A and an O(log n)-time computation for each odd number in A. What is the best-case running time of Algorithm X? What is the worst-case running time of Algorithm X? 2. Given an array, A, of n integers, give an O(n)-time algorithm that finds the longest subarray of A such that all the numbers in that subarray are in sorted order. Your algorithm...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT