complexity-theory

What are some of Drupal's shortcomings? [closed]

我与影子孤独终老i 提交于 2019-11-28 17:00:18
Drupal is very much a "Do Everything" CMS. There are modules that allow you to add almost any functionality, which is great. However, it feels like a lot of the features (v5 and v6) seem scattered around and unintuitive for the user. As a developer, I'm left with the feeling of having patched a site together using bubble gum and string. For example, to add text to the default search box (that disappears when clicked), you have to either add some jQuery code OR override the theme. I've also found the menu system more complicated than it should be. Am I the only one with this opinion? What

Complexity of recursive factorial program

 ̄綄美尐妖づ 提交于 2019-11-28 16:48:27
问题 What's the complexity of a recursive program to find factorial of a number n ? My hunch is that it might be O(n) . 回答1: If you take multiplication as O(1) , then yes, O(N) is correct. However, note that multiplying two numbers of arbitrary length x is not O(1) on finite hardware -- as x tends to infinity, the time needed for multiplication grows (e.g. if you use Karatsuba multiplication, it's O(x ** 1.585) ). You can theoretically do better for sufficiently huge numbers with Schönhage

What's faster: inserting into a priority queue, or sorting retrospectively?

被刻印的时光 ゝ 提交于 2019-11-28 16:34:06
What's faster: inserting into a priority queue, or sorting retrospectively? I am generating some items that I need to be sorted at the end. I was wondering, what is faster in terms of complexity: inserting them directly in a priority_queue or a similar data structure, or using a sort algorithm at end? Inserting n items into a priority queue will have asymptotic complexity O( n log n ) so in terms of complexity, it’s not more efficient than using sort once, at the end. Whether it’s more efficient in practice really depends. You need to test. In fact, in practice, even continued insertion into a

Difference between O(n) and O(log(n)) - which is better and what exactly is O(log(n))?

你离开我真会死。 提交于 2019-11-28 15:56:30
问题 This is my first course in data structures and every lecture / TA lecture , we talk about O(log(n)) . This is probably a dumb question but I'd appreciate if someone can explain to me exactly what does it mean !? 回答1: It means that the thing in question (usually running time) scales in a manner that is consistent with the logarithm of its input size. Big-O notation doesn't mean an exact equation, but rather a bound . For instance, the output of the following functions is all O(n): f(x) = 3x g

What's Up with O(1)?

萝らか妹 提交于 2019-11-28 13:51:14
问题 I have been noticing some very strange usage of O(1) in discussion of algorithms involving hashing and types of search, often in the context of using a dictionary type provided by the language system, or using dictionary or hash-array types used using array-index notation. Basically, O(1) means bounded by a constant time and (typically) fixed space. Some pretty fundamental operations are O(1), although using intermediate languages and special VMs tends to distort ones thinking here (e.g., how

Differences between time complexity and space complexity?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 13:41:56
问题 I have seen that in most cases the time complexity is related to the space complexity and vice versa. For example in an array traversal: for i=1 to length(v) print (v[i]) endfor Here it is easy to see that the algorithm complexity in terms of time is O(n), but it looks to me like the space complexity is also n (also represented as O(n)?). My question: is it possible that an algorithm has different time complexity than space complexity? 回答1: The time and space complexities are not related to

General rules for simplifying SQL statements

南笙酒味 提交于 2019-11-28 13:23:05
问题 I'm looking for some "inference rules" (similar to set operation rules or logic rules) which I can use to reduce a SQL query in complexity or size. Does there exist something like that? Any papers, any tools? Any equivalencies that you found on your own? It's somehow similar to query optimization, but not in terms of performance. To state it different: Having a (complex) query with JOINs, SUBSELECTs, UNIONs is it possible (or not) to reduce it to a simpler, equivalent SQL statement, which is

What's the complexity of for i: for o = i+1

家住魔仙堡 提交于 2019-11-28 12:13:08
问题 for i = 0 to size(arr) for o = i + 1 to size(arr) do stuff here What's the worst-time complexity of this? It's not N^2, because the second one decreases by one every i loop. It's not N, it should be bigger. N-1 + N-2 + N-3 + ... + N-N+1. 回答1: It is N ^ 2 , since it's the product of two linear complexities. (There's a reason asymptotic complexity is called asymptotic and not identical ...) See Wikipedia's explanation on the simplifications made. 回答2: Think of it like you are working with a n x

c++ - unordered_map complexity

喜夏-厌秋 提交于 2019-11-28 12:01:14
I need to create a lookup function where a (X,Y) pair corresponds to a specific Z value. One major requirement for this is that I need to do it in as close to O(1) complexity as I can. My plan is to use an unordered_map. I generally do not use a hash table for lookup, as the lookup time has never been important to me. Am I correct in thinking that as long as I built the unordered_map with no collisions, my lookup time will be O(1)? My concern then is what the complexity becomes if there the key is not present in the unordered map. If I use unordered_map::find():, for example, to determine

Efficiently find all connected induced subgraphs

被刻印的时光 ゝ 提交于 2019-11-28 09:19:52
Is there an efficient(*) algorithm to find all the connected (induced) subgraphs of a connected undirected vertex-labelled graph? (*) I appreciate that, in the general case, any such algorithm may have O(2^n) complexity because, for a clique (Kn), there are 2^n connected subgraphs. However, the graphs I'm typically dealing with will have far fewer connected subgraphs, so I'm looking for a way to generate them without having to consider all 2^n subgraphs and throw away those that aren't connected (as in the solution to this question ). An algorithm that has running time that's linear in the