asymptotic-complexity

The time complexity of counting sort

自闭症网瘾萝莉.ら 提交于 2021-01-26 23:59:04
问题 I am taking an algorithms course and there I saw that the time complexity of counting sort is O(n+k) where k is the range of numbers and n is the input size. My question is, when the difference between k and n is too much, such as when k=O(n 2 )or O(n 3 ), can we say that the complexity is O(n 2 ) or O(n 3 )? Then in this case counting sort is not a wise approach and we can use merge sort. Am I right? 回答1: Yes, you are exactly right on all counts. Furthermore, we can make stronger statements:

The time complexity of counting sort

南笙酒味 提交于 2021-01-26 23:52:28
问题 I am taking an algorithms course and there I saw that the time complexity of counting sort is O(n+k) where k is the range of numbers and n is the input size. My question is, when the difference between k and n is too much, such as when k=O(n 2 )or O(n 3 ), can we say that the complexity is O(n 2 ) or O(n 3 )? Then in this case counting sort is not a wise approach and we can use merge sort. Am I right? 回答1: Yes, you are exactly right on all counts. Furthermore, we can make stronger statements:

The time complexity of counting sort

会有一股神秘感。 提交于 2021-01-26 23:52:03
问题 I am taking an algorithms course and there I saw that the time complexity of counting sort is O(n+k) where k is the range of numbers and n is the input size. My question is, when the difference between k and n is too much, such as when k=O(n 2 )or O(n 3 ), can we say that the complexity is O(n 2 ) or O(n 3 )? Then in this case counting sort is not a wise approach and we can use merge sort. Am I right? 回答1: Yes, you are exactly right on all counts. Furthermore, we can make stronger statements:

Is there a programmatic way or eclipse plugin to calculate big O notation for java method [closed]

走远了吗. 提交于 2020-12-02 08:24:24
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 months ago . Improve this question Is there a programmatic way or eclipse plugin to calculate big-O notation for java method ? 回答1: No, there isn't such plugin, and if it was, it would be a mere approximation. Namely, even determining whether the program will finish running or not is

Is there a programmatic way or eclipse plugin to calculate big O notation for java method [closed]

蓝咒 提交于 2020-12-02 08:20:18
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 months ago . Improve this question Is there a programmatic way or eclipse plugin to calculate big-O notation for java method ? 回答1: No, there isn't such plugin, and if it was, it would be a mere approximation. Namely, even determining whether the program will finish running or not is

Python converting a list to set, big O

人盡茶涼 提交于 2020-05-13 13:37:52
问题 and thanks for help words = [....#Big list of words] words_set = set(words) I have hard time determine what is the complexity of set(words) when n=len(words). Is it O(n) since it moves on all the items of the list, or O(l(n-l)) when l is a single word length? Thanks for help! If there is a difference between WC and BC too. Edit: don't mind O(l(n-l)) it's mistake for repeating substring big O. 回答1: I don't understand your second option, but iterating a list is O(n) and you must iterate the

How can merge sort have multiple big-oh values?

随声附和 提交于 2020-01-16 00:36:43
问题 In What exactly does big Ө notation represent?, the most upvoted answer contains the following statement: For example, merge sort worst case is both O(n*log(n)) and Omega(n*log(n)) - and thus is also Ө(n*log(n)) , but it is also O(n^2) , since n^2 is asymptotically "bigger" than it. However, it is not Ө(n^2) , Since the algorithm is not Omega(n^2) . I have two questions: How do you determine that the worst case is O(n*log(n)) and Omega(n*log(n)) . In "Introduction to Algorithms" you determine

why O(2n^2) and O(100 n^2) same as O(n^2) in algorithm complexity?

青春壹個敷衍的年華 提交于 2020-01-13 05:38:14
问题 I am new in the algorithm analysis domain. I read here in the Stack Overflow question "What is a plain English explanation of "Big O" notation?" that O(2n^2) and O(100 n^2) are the same as O(n^2) . I don't understand this, because if we take n = 4, the number of operations will be: O(2 n^2) = 32 operations O(100 n^2) = 1600 operations O(n^2) = 16 operations Can any one can explain why we are supposed to treat these different operation counts as equivalent? 回答1: Why this is true can be derived

Big O Notation of an expression

喜夏-厌秋 提交于 2020-01-12 03:55:06
问题 If I have an algorithm that takes 4n^2 + 7n moves to accomplish, what is its O? O(4n^2)? O(n^2)? I know that 7n is cut off, but I don't know if I should keep the n^2 coefficient or not. Thanks 回答1: You should drop any coefficients because the question is really asking "on the order of", which tries to characterize it as linear, exponential, logarithmic, etc... That is, when n is very large, the coefficient is of little importance. This also explains why you drop the +7n, because when n is

Time complexity of a recursive function

点点圈 提交于 2020-01-07 09:29:31
问题 I have a Java function that receives a matrix (2-dimensional array[][]) and creates a dynamic array of options of changes for this array, and then recursively creates a dynamic array for each option of the dynamic array. Eventually for each option in one of N options it creates N other options. I was told that the function of time complexity of it is T(n)=T(n)*n, is this possible? And what is the asymptotic time complexity of it in big O notation? 回答1: If the recurrence relation is T(n)=nT(n)