theory

How a RegEx engine works [closed]

随声附和 提交于 2019-11-29 20:17:47
In learning Regular Expressions it had me wondering how the underlying engine works. Probably more specifically, I'd like to know more about how it evalutates, prioritizies and parses the expression. I feel the RegEx engine is a blackbox to me, and I would really enjoy deciphering it. So I'd like to ask if there are some great resources that I could read up on that discuss RegEx engine theory. *Note: I am not interested in building an engine, just learning the inner workings of it. There are two main classes of regex engines. Those based on Finite State Automaton . These are generally the

What's a Turing machine?

蓝咒 提交于 2019-11-29 19:40:44
What is a Turing machine and why do people keep mentioning it? My IBM PC is all I need to do my computation! Why does anyone care about these machines? The reason that Turing Machines are a big deal has to do with the study of classical Computing Science or Theory of Computation type stuff. It's basically about analyzing the general properties of a computer, such as what theoretical abilities and limitations a computer has, as well as what we mean when we talk about "computing" something. One example of something that one might study using Turing Machines is The Halting Problem . While this

What's a “canonical path”?

僤鯓⒐⒋嵵緔 提交于 2019-11-29 19:31:19
That's a theory question. I've searched over the internet with no satisfying luck, I just want to understand what's this jargon. I've seen examples of Java, JSON, etc but I couldn't find in Google nor here in StackOverflow a simple explanation, no code needed =P So, an absolute path it's a way to get to a certain file or location describing the full route to it, the full path, and it's OS dependent (the absolute paths for Windows and Linux for example, are different) A relative path it's a route to a file or location which it's described from the current location .. (two dots) indicating a

Steps to creating an NFA from a regular expression

霸气de小男生 提交于 2019-11-29 19:27:53
I'm having issues 'describing each step' when creating an NFA from a regular expression. The question is as follows: Convert the following regular expression to a non-deterministic finite-state automaton (NFA), clearly describing the steps of the algorithm that you use: (b|a)*b(a|b) I've made a simple 3-state machine but it's very much from intuition. This is a question from a past exam written by my lecturer, who also wrote the following explanation of Thompson's algorithm: http://www.cs.may.ie/staff/jpower/Courses/Previous/parsing/node5.html Can anyone clear up how to 'describe each step

Why can Conway’s Game of Life be classified as a universal machine?

青春壹個敷衍的年華 提交于 2019-11-29 19:05:17
I was recently reading about artificial life and came across the statement, "Conway’s Game of Life demonstrates enough complexity to be classified as a universal machine." I only had a rough understanding of what a universal machine is, and Wikipedia only brought me as close to understanding as Wikipedia ever does. I wonder if anyone could shed some light on this very sexy statement? Conway's Game of Life seems, to me, to be a lovely distraction with some tremendous implications: I can't make the leap between that and calculator? Is that even the leap that I should be making? You can build a

Is multiplication allowed in relational algebra?

那年仲夏 提交于 2019-11-29 18:16:30
I have a relation R ------- cid sid gradepoint credits CS425 001 4.0 3 I need to calculate the GPA. There are more rows, but I believe if I just get this answered I should be ok with the rest. I need to do gradepoint * credits . How do I express this with a relational algebra expression? My best guess is: , but I'm not sure if I can multiply attributes with anything other than a constant. Relational algebra doesn't address domain-specific operations. It neither includes nor excludes it, just like real algebra neither includes nor excludes operations on relations. If you allow multiplication by

The consequences and pros/cons of flushing the stream in c++

非 Y 不嫁゛ 提交于 2019-11-29 16:09:22
问题 I have recently read an article which stated that using \n is preferable to using std::endl because endl also flushes the stream. But when I looked for a bit more information on the topic I found a site which stated: If you are in a situation where you have to avoid buffering, you can use std::endl instead of ‘\n’ Now here comes my question: In which situation is it preferable not to write to the buffer? Because I only saw advantages of that technique. Isn't it also safer to write to the

Generate all subset sums within a range faster than O((k+N) * 2^(N/2))?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 14:37:33
Is there a way to generate all of the subset sums s 1 , s 2 , ..., s k that fall in a range [A,B] faster than O((k+N)*2 N/2 ), where k is the number of sums there are in [A,B]? Note that k is only known after we have enumerated all subset sums within [A,B]. I'm currently using a modified Horowitz-Sahni algorithm. For example, I first call it to for the smallest sum greater than or equal to A, giving me s 1 . Then I call it again for the next smallest sum greater than s 1 , giving me s 2 . Repeat this until we find a sum s k+1 greater than B. There is a lot of computation repeated between each

What are good use cases for JavaScript self executing anonymous functions? [closed]

二次信任 提交于 2019-11-29 12:19:22
I understand what a self executing anonymous function is but I am having trouble understanding where I would use them and why. This could be because I often use jQuery. Could you please provide examples of good use cases? Basically, a self-executing anonymous function (more technically referred to as an IIFE or immediately invoked function expression) is the same as declaring a named function and then immediately calling it. The only difference with an IIFE is that is has no name so it can only be executed in place (not called from elsewhere) and consequently doesn't add a name to the current

What are the differences between Hashmap vs Hashtable in theory?

半腔热情 提交于 2019-11-29 12:07:30
Are there are differences between hashmap and hashtable in theory? I don't mean in the concrete definitions given in Java (or the implementation), but in theory. Isn't a hashtable a map that uses hashing ... hence a hashmap? woliveirajr According to Wikipedia , they are the same: In computing, a hash table (hash map) is a data structure used to implement an associative array (...) According to Wikibooks , it's the same: A hash table, or a hash map, is a data structure that associates keys with values. Some answer on StackOverflow also states: Hashtable is often useful (they are also called