theory

Explain the difference between a data *structure* and a data *type* [closed]

假如想象 提交于 2020-01-19 06:34:08
问题 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 . While trying to answer What is the difference between a composite data type and a data structure? I realized that while I have a clear idea of what a data type is , and how it is not the same thing as a data structure , I cannot put the difference into words. If you were teaching an intro CS course, how would

Is it possible for a computer to “learn” a regular expression by user-provided examples?

随声附和 提交于 2020-01-18 04:48:07
问题 Is it possible for a computer to "learn" a regular expression by user-provided examples? To clarify: I do not want to learn regular expressions. I want to create a program which "learns" a regular expression from examples which are interactively provided by a user, perhaps by selecting parts from a text or selecting begin or end markers. Is it possible? Are there algorithms, keywords, etc. which I can Google for? EDIT : Thank you for the answers, but I'm not interested in tools which provide

Is it possible for a computer to “learn” a regular expression by user-provided examples?

情到浓时终转凉″ 提交于 2020-01-18 04:47:25
问题 Is it possible for a computer to "learn" a regular expression by user-provided examples? To clarify: I do not want to learn regular expressions. I want to create a program which "learns" a regular expression from examples which are interactively provided by a user, perhaps by selecting parts from a text or selecting begin or end markers. Is it possible? Are there algorithms, keywords, etc. which I can Google for? EDIT : Thank you for the answers, but I'm not interested in tools which provide

Halting in non-Turing-complete languages

耗尽温柔 提交于 2020-01-12 13:54:54
问题 The halting problem cannot be solved for Turing complete languages and it can be solved trivially for some non-TC languages like regexes where it always halts. I was wondering if there are any languages that has both the ability to halt and not halt but admits an algorithm that can determine whether it halts. 回答1: Yes. One important class of this kind are primitive recursive functions. This class includes all of the basic things you expect to be able to do with numbers (addition,

Halting in non-Turing-complete languages

自作多情 提交于 2020-01-12 13:53:52
问题 The halting problem cannot be solved for Turing complete languages and it can be solved trivially for some non-TC languages like regexes where it always halts. I was wondering if there are any languages that has both the ability to halt and not halt but admits an algorithm that can determine whether it halts. 回答1: Yes. One important class of this kind are primitive recursive functions. This class includes all of the basic things you expect to be able to do with numbers (addition,

Why is multiplying cheaper than dividing?

核能气质少年 提交于 2020-01-12 07:21:09
问题 I recently wrote a Vector 3 class, and I submitted my normalize() function for reviewal to a friend. He said it was good, but that I should multiply by the reciprocal where possible because "multiplying is cheaper than dividing" in CPU time. My question simply is, why is that? 回答1: Think about it in terms of elementary operations that hardware can more easily implement -- add, subtract, shift, compare. Multiplication even in a trivial setup requires fewer such elementary steps -- plus, it

Storing item positions (for ordering) in a database efficiently

≡放荡痞女 提交于 2020-01-11 21:26:11
问题 Scenario: There is a database of movies a user owns, movies are displayed on a page called "my-movies", the movies can be displayed in the order that the user desires. For example "Fight Club" in position #1, "Drive" in position #3 and so on and so forth. The obvious solution is to store a position with each item, for example: movieid, userid, position 1 | 1 | 1 2 | 1 | 2 3 | 1 | 3 Then when outputting the data is ordered by the position. This method works fine for output however it has a

What is the relationship between event loop and Promise [duplicate]

主宰稳场 提交于 2020-01-11 18:54:00
问题 This question already has answers here : Promise vs setTimeout (5 answers) Closed 2 years ago . I am curious about the relationship between Event Loop and Promise. The demo exposes the question. I expected the p1 fulfilled appear in the middle, since they queue a task to the same task queue and are executed one by one. var p1 = new Promise(function(resolve, reject){ resolve(1) }) setTimeout(function(){ console.log("will be executed at the top of the next Event Loop") },0) p1.then(function

Is there any difference between md5 and sha1 in this situation?

穿精又带淫゛_ 提交于 2020-01-04 04:27:03
问题 It is known that 1. if ( md5(a) == md5(b) ) 2. then ( md5(a.z) == md5(b.z) ) 3. but ( md5(z.a) != md5(z.b) ) where the dots concatenate the strings. EDIT --- Here you can find a and b : http://www.mscs.dal.ca/~selinger/md5collision/ Check these links: hexpaste.com/qzNCBRYb/1 - this is a.md5(a)."kutykurutty" hexpaste.com/mSXMl13A/1 - this is b.md5(b)."kutykurutty" They share the same md5 hash, yet they are different. But you can call these strings a' and b' , because they have the same md5. --

U-matrix and self organizing maps

大憨熊 提交于 2020-01-03 09:11:29
问题 I am trying to understand SOMs. I am confused about when people post images representing the image of data gotten my using SOM to map data to the map space. It is said that the U-matrix is used. But we have a finite grid of neurons so how do you get a "continous" image ? For example starting with a 40x40 grid there are 1600 neurons. Now compute U-matrix but how do you plot these numbers now to get visualization ? Links: SOM tutorial with visualization SOM from Wikipedia 回答1: The U-matrix