complexity-theory

What does Õ (omicron tilde) mean in complexity Õ(n) vs O(n) [closed]

偶尔善良 提交于 2019-12-18 14:25:09
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . I've never seen this notation for complexity: Õ(n). It comes up in the context of learning in stochastic algorithms. Anyone know this notation? You can't exactly google this... EDIT: SOLVED I think people have pointed out the right answer below. In my case Õ() is used to hide an exponential growth of a tree. 回答1

What is the complexity of this nested triple for loop?

穿精又带淫゛_ 提交于 2019-12-18 13:21:03
问题 I have searched a bit on StackOverflow and have understood the complexity up to the point of the j-loop, which is O(n 2 ) . However with the nested addition of the k-loop, I am confused as why the complexity becomes O(n 3 ) . Can someone help me understand this? From my understanding, the i-loop have n iterations and the j-loop have 1+2+3+...+n iterations n*(n+1)/2 which is O(n 2 ) . for(i = 1; i < n; i++) { for(j = i+1; j <= n; j++) { for(k = i; k <= j; k++) { // Do something here... } } }

Java CharAt() and deleteCharAt() performance

筅森魡賤 提交于 2019-12-18 11:23:35
问题 I've been wondering about the implementation of charAt function for String/StringBuilder/StringBuffer in java what is the complexity of that ? also what about the deleteCharAt() in StringBuffer/StringBuilder ? 回答1: For String , StringBuffer , and StringBuilder , charAt() is a constant-time operation. For StringBuffer and StringBuilder , deleteCharAt() is a linear-time operation. StringBuffer and StringBuilder have very similar performance characteristics. The primary difference is that the

What is O(1) space complexity?

僤鯓⒐⒋嵵緔 提交于 2019-12-18 11:21:12
问题 I am having a hard time understanding what is O(1) space complexity. I understand that it means that the space required by the algorithm does not grow with the input or the size of the data on which we are using the algorithm. But what does it exactly mean? If we use an algorithm on a linked list say 1->2->3->4, to traverse the list to reach "3" we declare a temporary pointer. And traverse the list until we reach 3. Does this mean we still have O(1) extra space? Or does it mean something

Efficient way of calculating likeness scores of strings when sample size is large?

早过忘川 提交于 2019-12-18 11:09:44
问题 Let's say that you have a list of 10,000 email addresses, and you'd like to find what some of the closest "neighbors" in this list are - defined as email addresses that are suspiciously close to other email addresses in your list. I'm aware of how to calculate the Levenshtein distance between two strings (thanks to this question), which will give me a score of how many operations are needed to transform one string into another. Let's say that I define "suspiciously close to another email

Quickly checking if set is superset of stored sets

 ̄綄美尐妖づ 提交于 2019-12-18 11:09:12
问题 The problem I am given N arrays of C booleans. I want to organize these into a datastructure that allows me to do the following operation as fast as possible: Given a new array, return true if this array is a "superset" of any of the stored arrays. With superset I mean this: A is a superset of B if A[i] is true for every i where B[i] is true. If B[i] is false, then A[i] can be anything. Or, in terms of sets instead of arrays: Store N sets (each with C possible elements) into a datastructure

Complexity of factorial recursive algorithm

白昼怎懂夜的黑 提交于 2019-12-18 11:06:23
问题 Today in class my teacher wrote on the blackboard this recursive factorial algorithm: int factorial(int n) { if (n == 1) return 1; else return n * factorial(n-1); } She said that it has a cost of T(n-1) + 1 . Then with iteration method she said that T(n-1) = T(n-2) + 2 = T(n-3) + 3 ... T(n-j) + j , so the algorithm stops when n - j = 1 , so j = n - 1 . After that, she substituted j in T(n-j) + j , and obtained T(1) + n-1 . She directly said that for that n-1 = 2 (log 2 n-1) , so the cost of

Quicksort complexity when all the elements are same?

我是研究僧i 提交于 2019-12-18 10:44:17
问题 I have an array of N numbers which are same.I am applying Quick sort on it. What should be the time complexity of the sorting in this case. I goggled around this question but did not get the exact explanation. Any help would be appreciated. 回答1: This depends on the implementation of Quicksort. The traditional implementation which partitions into 2 ( < and >= ) sections will have O(n*n) on identical input. While no swaps will necessarily occur, it will cause n recursive calls to be made - each

Understanding Ukkonen's algorithm for suffix trees [duplicate]

左心房为你撑大大i 提交于 2019-12-18 10:35:08
问题 This question already has answers here : Ukkonen's suffix tree algorithm in plain English (7 answers) Closed 6 years ago . I'm doing some work with Ukkonen's algorithm for building suffix trees, but I'm not understanding some parts of the author's explanation for it's linear-time complexity. I have learned the algorithm and have coded it, but the paper which I'm using as the main source of information (linked bellow) is kinda confusing at some parts so it's not really clear for me why the

Explaining computational complexity theory

不想你离开。 提交于 2019-12-18 10:00:30
问题 Assuming some background in mathematics, how would you give a general overview of computational complexity theory to the naive? I am looking for an explanation of the P = NP question. What is P? What is NP? What is a NP-Hard? Sometimes Wikipedia is written as if the reader already understands all concepts involved. 回答1: Hoooo, doctoral comp flashback. Okay, here goes. We start with the idea of a decision problem, a problem for which an algorithm can always answer "yes" or "no." We also need