computer-science

Can I always convert mutable-only algorithms to single-assignment and still be efficient?

拜拜、爱过 提交于 2019-11-28 03:33:06
问题 The Context The context of this question is that I want to play around with Gene Expression Programming (GEP), a form of evolutionary algorithm, using Erlang. GEP makes use of a string based DSL called ' Karva notation '. Karva notation is easily translated into expression parse trees, but the translation algorithm assumes an implementation having mutable objects: incomplete sub-expressions are created early-on the translation process and their own sub-expressions are filled-in later-on with

Hash Code and Checksum - what's the difference?

大城市里の小女人 提交于 2019-11-28 02:54:35
My understanding is that a hash code and checksum are similar things - a numeric value, computed for a block of data, that is relatively unique. i.e. The probability of two blocks of data yielding the same numeric hash/checksum value is low enough that it can be ignored for the purposes of the application. So do we have two words for the same thing, or are there important differences between hash codes and checksums? I would say that a checksum is necessarily a hashcode . However, not all hashcodes make good checksums. A checksum has a special purpose --- it verifies or checks the integrity of

What algorithms do popular C++ compilers use for std::sort and std::stable_sort?

无人久伴 提交于 2019-11-28 02:38:43
问题 What algorithms do popular C++ compilers use for std::sort and std::stable_sort? I know the standard only gives certain performance requirements, but I'd like to know which algorithms popular implementations use in practice. The answer would be more useful if it cited references for each implementation. 回答1: First of all: the compilers do not provide any implementation of std::sort . Whilst traditionally each compiler comes prepackaged with a Standard Library implementation (which heavily

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

Why are NP problems called that way (and NP-hard and NP-complete)?

扶醉桌前 提交于 2019-11-27 21:14:57
问题 Really.. I'm having the last test for graduation this Tuesday, and that's one of the things I just never could understand. I realize that a solution for NP problem can be verfied in polynomial time. But what does determinism has to do with that? And if you could explain me where NP-complete and NP-hard got their names, that would be great (I'm pretty sure I get the meaning of them, I just don't see what their names have to do with what they are). Sorry if that's trivial, I just can't seem to

two's complement, why the name “two”

泪湿孤枕 提交于 2019-11-27 20:23:04
问题 i know unsigned,two's complement, ones' complement and sign magnitude, and the difference between these, but what i'm curious about is: why it's called two's(or ones') complement, so is there a more generalize N's complement? in which way did these genius deduce such a natural way to represent negative numbers? 回答1: Two's complement came about when someone realized that 'going negative' by subtracting 1 from 0 and letting the bits rollunder actually made signed arithmetic simpler because no

Converting EBNF to BNF

喜你入骨 提交于 2019-11-27 19:32:55
It's been a few years since my computer-language class and so I've forgotten the finer points of BNF's and EBNF's and I don't have a textbook next to me. Specifically, I've forgotten how to convert an EBNF into BNF. From what little I remember, I know that one of the main points is to convert { term } into <term> | <many-terms> . But I don't remember the other rules. I've tried to look this up online but I can only find links to either homework questions, or a small comment about converting terms with curly braces. I can't find an exhaustive list of rules that define the translation. 500 -

Why binary and not ternary computing?

对着背影说爱祢 提交于 2019-11-27 17:47:16
Isn't a three state object immedately capable of holding more information and handling larger values? I know that processors currently use massive nets of XOR gates and that would need to be reworked. Since we are at 64 bit (we can represent 2^63 possible states) computing the equivalent ternary generation could support number with 30 more tens places log(3^63-2^63). I imagine it is as easy to detect the potential difference between +1 and 0 as it is between -1 and 0. Would some compexity of the hardware, power consumption, or chip density offset any gains in storage and computing power?

What does 'predicate' mean in the context of computer science? [duplicate]

断了今生、忘了曾经 提交于 2019-11-27 17:28:37
This question already has an answer here: What is a predicate? 11 answers Specifically I've seen it used in the context of text filtering. As if "predicate" == "filter criteria". Is this accurate? Prasoon Saurav It is a term most commonly used in the field of Mathematical Logic. From wikipedia In mathematics, a predicate is either a relation or the boolean-valued function that amounts to the characteristic function or the indicator function of such a relation. A function P: X→ {true, false} is called a predicate on X. When P is a predicate on X, we sometimes say P is a property of X. .

What is the 'expression problem'?

喜你入骨 提交于 2019-11-27 17:23:43
I have a rough idea about what this is but if someone has an explanation of the 'expression problem' that they think is succinct and intuitive I would love to hear it. Watch this lecture . The idea is that your program is a combination of a datatype and operations over it. The problem asks for an implementation that allows to add new cases of the type and new operations without the need for recompilation of the old modules and keeping static type safety(no casts or runtime type checks). It's interesting to notice that in functional programming languages it's easy to add new operations, but