theory

What is the Zipper data structure and should I be using it?

≯℡__Kan透↙ 提交于 2019-11-28 03:54:55
The question is simple: I cannot understand the Zipper data structure. My question is related to its uses with a Tree. I want to understand how can I change the tree node using zipper. And how not to copy the whole tree (or the most part of it). Please, clarify if I'm wrong with zipper. Maybe it cannot help with the tree update? Or, maybe, it is possible to update the tree and I just cannot see the way? Let's start with the Zipper-analog for lists. If you'd like to modify the nth element of a list, it takes O(n) because you have to copy the n-1 first elements. Instead, you can keep the list as

Does Presenter in Model-View-Presenter create views?

大憨熊 提交于 2019-11-28 03:29:09
How are Views created in MVP? Does the Presenter always create them (in addition to View in case of subviews)? Or is it a separate third-party component or App or something that creates them? Let's also add that I'm probably going to do this on Dojo Toolkit/ExtJS (JavaScript that is). So, I have these code lines: var v = new MyApp.view.User(); var p = new MyApp.presenter.User(); where should both lines go exactly? Does the presenter instantiate the view, or vice-versa? And what instantiates the first instance? Marijn It depends ... The main goal of MVP is to separate complex decision logic

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

自闭症网瘾萝莉.ら 提交于 2019-11-28 03:18:34
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, impossible to solve. The most recent time I came up with it was when studying type checkers. Our class realized that it would be impossible to write a perfect type checker (one that would accept all programs that would run without type errors, and reject all programs that would run with type errors) because this would, in

How would you code an anti plagiarism site?

拥有回忆 提交于 2019-11-28 03:07:09
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 duplicate? Does it use levenshtein() ? My language of choice is PHP. UPDATE I'm thinking of not checking

What is starvation?

左心房为你撑大大i 提交于 2019-11-28 03:04:31
In multitasking systems, some abnormal conditions prevent progress of executing processes or threads. I'll refer to both processes and threads simply as "processes". Two of these conditions are called dead-lock and live-lock. The former refers to processes which are blocking each other, thus preventing either from executing. The latter refers to processes which prevent each other from progressing, but do not actually block the execution. For instance, they might continually cause each other to rollback transactions, neither ever being able to finish them. Another condition is known as resource

Coupling and cohesion

家住魔仙堡 提交于 2019-11-28 02:49:56
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? 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 can be replaced without disrupting the system. Tight: You and your wife. Cohesion Low: The convenience store

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

送分小仙女□ 提交于 2019-11-28 02:30:46
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. :) P stands for polynomial time. NP stands for non-deterministic polynomial time. Definitions: Polynomial time means that the complexity of the algorithm is O(n^k), where n is the size of your data (e. g. number of elements in a list to be sorted), and k is a constant. Complexity is time measured in the number of operations it would take, as a function of the number of data items

Legitimate uses of Object(o)

筅森魡賤 提交于 2019-11-28 01:23:39
When an object value is provided to the Object constructor, that value will be returned unchanged. So, given an object obj : obj === new Object( obj ) and obj === Object( obj ) Then, what's the point of doing Object( obj ) in the first place? I can understand doing Object( 'foo' ) , or Object( 123 ) - it creates a wrapper object for the primitive value, but if we already have an object obj , why would we do Object( obj ) ? Is this pattern useless? The comparison will check whether obj is a real object. It is nearly equivalent to checking for typeof obj == "object" Yet, that is also true for

Correct implementation of min

南笙酒味 提交于 2019-11-27 21:20:10
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 example of alpha-geeks going a bit too far? Recommended implementation: template <class LHS, class RHS,

CSS metaphysics: WHY is page vertical alignment so difficult?

守給你的承諾、 提交于 2019-11-27 19:59:47
Relative to the page, horizontal alignment in CSS is easy - a margin:0 auto gets you by much of the time, and a text-align:center for some other cases. My question to the gurus is not how to vertically align, but why is it so much more difficult? Why isn't there margin:auto 0 ? I mean, from a programming perspective. Theoretically, it seems like the same algorithms would apply to both types of centering. Good question and I don't know, but I would suspect the root of the problem is going to lie in HTML and therefore it's rendering engines being originally intended for document semantics as