theory

Are the grammars of modern programming languages context-free or context-sensitive?

∥☆過路亽.° 提交于 2019-11-27 06:01:18
问题 Are the C++, C# or Java languages context-free or context-sensitive? 回答1: C++ is neither context-free nor context-sensitive, since the template system is Turing-complete and determining whether a piece of C++ code is legal C++ is undecidably hard. For example, I could define a template class that simulates a TM on a string and then creates a constant with value 1 if the machine accepts and 0 if it does not. If I did that, then the following code would be legal iff the TM halted on the given

What is a database transaction?

你说的曾经没有我的故事 提交于 2019-11-27 05:53:37
Can someone provide a straightforward (but not simpler than possible) explanation of a transaction as applied to computing (even if copied from Wikipedia)? Vilx- A transaction is a unit of work that you want to treat as "a whole." It has to either happen in full or not at all. A classical example is transferring money from one bank account to another. To do that you have first to withdraw the amount from the source account, and then deposit it to the destination account. The operation has to succeed in full. If you stop halfway, the money will be lost, and that is Very Bad. In modern databases

Why do I need “OR NULL” in MySQL when counting rows with a condition

最后都变了- 提交于 2019-11-27 05:29:22
There is a question about MySQL's COUNT() aggregate function that keeps popping into my head time to time. I would like to get some explanation to why it is working the way it is. When I started working with MySQL I quickly learned that its COUNT(condition) seems only to work properly if condition also contains an OR NULL in the end. In case of more complicated COUNT conditions it was an empirical process to find out where to put it exactly. In MSSQL you do not need this OR NULL to get proper results, so I would like to know the explanation for it. So, here is an example. Lets have a very

Purpose of singletons in programming

廉价感情. 提交于 2019-11-27 05:24:04
问题 This is admittedly a rather loose question. My current understanding of singletons is that they are a class that you set up in such a way that only one instance is ever created. This sounds a lot like a static class to me. The main difference being that with a static class you don't / can't instance it, you just use it such as Math.pi() . With a singleton class, you would still need to do something like singleton firstSingleton = new singleton(); firstSingleton.set_name("foo"); singleton

When have you come upon the halting problem in the field? [closed]

人走茶凉 提交于 2019-11-27 05:06:38
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . When have you ever personally come upon the halting problem in the field? This can be when a co-worker / boss suggested a solution which would violate the fundamental limits of computation, or when you realized yourself that a problem you were trying to solve was, in fact,

How would you code an anti plagiarism site?

╄→尐↘猪︶ㄣ 提交于 2019-11-27 05:03:50
问题 First, please note, that I am interested in how something like this would work, and am not intending to build it for a client etc, as I'm sure there may already be open source implementations. How do the algorithms work which detect plagiarism in uploaded text? Does it use regex to send all words to an index, strip out known words like 'the', 'a', etc and then see how many words are the same in different essays? Does it them have a magic number of identical words which flag it as a possible

Coupling and cohesion

房东的猫 提交于 2019-11-27 04:58:45
问题 I'm trying to boil down the concepts of coupling and cohesion to a concise definition. Can someone give me a short and understandable explanation (shorter than the definitions on Wikipedia here and here)? How do they interact? Thanks. Anybody have a good, short example? 回答1: Coupling Loose: You and the guy at the convenience store. You communicate through a well-defined protocol to achieve your respective goals - you pay money, he lets you walk out with the bag of Cheetos. Either one of you

What's “P=NP?”, and why is it such a famous question? [closed]

家住魔仙堡 提交于 2019-11-27 04:54:52
问题 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 . The question of whether P=NP is perhaps the most famous in all of Computer Science. What does it mean? And why is it so interesting? Oh, and for extra credit, please post a proof of the statement's truth or falsehood. :) 回答1: P stands for polynomial time. NP stands for non-deterministic polynomial time.

Correct implementation of min

旧时模样 提交于 2019-11-27 04:31:02
问题 At time 0:43:15 in this Tech-Talk about D, The implementation of the min function is discussed. Concerns about "stability" and "extra shuffling (if values are equal)" when being used in some algorithm(s) is proposed as one of the reasons for the implementation shown. Can anyone provide a real/practical use-case (or provide a more detailed explanation) where this specific implementation of min is "stable" (aka better) as opposed to its other possible implementation? Or is this just another

How are hash functions like MD5 unique?

你说的曾经没有我的故事 提交于 2019-11-27 03:22:44
I'm aware that MD5 has had some collisions but this is more of a high-level question about hashing functions. If MD5 hashes any arbitrary string into a 32-digit hex value, then according to the Pigeonhole Principle surely this can not be unique, as there are more unique arbitrary strings than there are unique 32-digit hex values. You're correct that it cannot guarantee uniqueness, however there are approximately 3.402823669209387e+38 different values in a 32 digit hex value (16^32). That means that, assuming the math behind the algorithm gives a good distribution, your odds are phenomenally