time-complexity

T(n) = T(n/10) + T(an) + n, how to solve this?

混江龙づ霸主 提交于 2021-01-20 11:21:06
问题 Update: I'm still looking for a solution without using something from outside sources. Given: T(n) = T(n/10) + T(an) + n for some a , and that: T(n) = 1 if n < 10 , I want to check if the following is possible (for some a values, and I want to find the smallest possible a ): For every c > 0 there is n 0 > 0 such that for every n > n 0 , T(n) >= c * n I tried to open the function declaration step by step but it got really complicated and I got stuck since I see no advancement at all. Here is

Dynamic Programming Fibonacci algorithm

☆樱花仙子☆ 提交于 2021-01-20 09:35:17
问题 I'm working on an algorithm to calculate a Fibonacci number and got the pseudo code for it but I can't figure out how much time it takes to run. I think it runs at O(n) but not quite sure. Here is the code: Algorithm Fast-Fibonacci(n) Let fib[0] and fib[1] be 1. for each i from 2 to n, do: Let fib[i] be fib[i - 2] + fib[i - 1]. end of loop return fib[n]. Thanks for any help. 回答1: You are correct that this takes O(n) as you are just counting sequentially from 2 to n to fill your array. If you

Additivity of time complexity?

点点圈 提交于 2021-01-07 06:34:36
问题 I'm currently working on a project for school in which I have a time complexity restriction. I'm still beginning to learn to program so apologies of this question is stupid. Essentially, let's say I have a constraint that my program must satisfy the time complexity O(n 2 + m log m) , where n and m are some sizes of input. Does that mean that's the maximum time complexity any specific component of my program can run in? That is, if I have a ton of, say, O(n 2 + m) functions, but the most

Asymptotic lower bounding does not work. Why?

房东的猫 提交于 2021-01-07 03:15:04
问题 Ok so this is not a homework question obviously, but here is the thing: The bubble sort algorithm is said to be O(n^2), Ω(n). However, if we plot its time complexity as a graph (average case), and try to lower bound it, a more accurate lower bound would be Ω(n^2). However contextually we see that Ω(n) is correct. So why does lower bounding the algorithm's runtime does not work? 回答1: I think you're mixing up concepts: Lower bound vs upper bound: Ω(f(n)) is a lower bound, and O(f(n)) is an

Asymptotic lower bounding does not work. Why?

天大地大妈咪最大 提交于 2021-01-07 03:14:34
问题 Ok so this is not a homework question obviously, but here is the thing: The bubble sort algorithm is said to be O(n^2), Ω(n). However, if we plot its time complexity as a graph (average case), and try to lower bound it, a more accurate lower bound would be Ω(n^2). However contextually we see that Ω(n) is correct. So why does lower bounding the algorithm's runtime does not work? 回答1: I think you're mixing up concepts: Lower bound vs upper bound: Ω(f(n)) is a lower bound, and O(f(n)) is an

Amortized Time with Hash Table

六月ゝ 毕业季﹏ 提交于 2021-01-07 03:04:23
问题 I solved the first part of the question but stuck at the second part. I have an elevator and want to support the following: Init() Set the elevator to start from floor 0 and its travel direction to be up (This function is called only once and the direction can't be changed). O(1) AddStop(K) save into the DS that elevator should stop when it reaches floor k. O(log n) while n is the total number of stops for the elevator. NextStop() send the elevator to its next stop position, if it's in the

Why are not the way parameters/arguments passed considered for the time complexity of an algorithm?

被刻印的时光 ゝ 提交于 2021-01-07 02:39:30
问题 Is it not true that depending on the language that way the parameters/arguments are passed will have a different time complexity. Then why is this not factored in or considered in the algorithms or programs that books measure time complexity of? CLRS or Data Structures and Algorithm Analysis by Mark Allen Weiss never would add the time complexity of how the arguments are being passed for the total runtime of the program? Am I misunderstanding something? I know CLRS was pseudocode but the

Why are not the way parameters/arguments passed considered for the time complexity of an algorithm?

随声附和 提交于 2021-01-07 02:38:41
问题 Is it not true that depending on the language that way the parameters/arguments are passed will have a different time complexity. Then why is this not factored in or considered in the algorithms or programs that books measure time complexity of? CLRS or Data Structures and Algorithm Analysis by Mark Allen Weiss never would add the time complexity of how the arguments are being passed for the total runtime of the program? Am I misunderstanding something? I know CLRS was pseudocode but the

Can O(N+NM) be simplified to O(NM)?

江枫思渺然 提交于 2021-01-05 06:48:16
问题 Suppose that N and M are two parameters of an algorithm. Is the following simplification correct? O(N+NM) = O[N(1+M)] = O(NM) In other words, is it allowed to remove the constant in such a context? 回答1: TL;DR Yes Explanation By the definition of the Big-Oh notation, if a term inside the O(.) is provably smaller than a constant times another term for all sufficiently large values of the variable, then you can drop the smaller term. You can find a more precise definition of Big-Oh here, but

Can O(N+NM) be simplified to O(NM)?

。_饼干妹妹 提交于 2021-01-05 06:41:28
问题 Suppose that N and M are two parameters of an algorithm. Is the following simplification correct? O(N+NM) = O[N(1+M)] = O(NM) In other words, is it allowed to remove the constant in such a context? 回答1: TL;DR Yes Explanation By the definition of the Big-Oh notation, if a term inside the O(.) is provably smaller than a constant times another term for all sufficiently large values of the variable, then you can drop the smaller term. You can find a more precise definition of Big-Oh here, but