computer-science

NP-Complete VS NP-Hard

 ̄綄美尐妖づ 提交于 2019-12-04 14:23:54
I am trying to understand the difference between NP-Complete and NP-Hard. Below is my understanding An NP-Hard problem is one that is not solvable in polynomial time but can be verified in polynomial time. An NP-Complete problem is one that is in NP and is also NP-Hard. Is the above definition correct? If so, What about problems not In NP but NP-Hard. Wouldn't they be harder than NP-Complete problem, say they can only be solved and verified in exponential time? A NP problem (not NP-Hard problem) is a decision problem which can be verified in polynomial time. Maybe they are solvable in

Can this breadth-first search be made faster?

不打扰是莪最后的温柔 提交于 2019-12-04 12:35:15
问题 I have a data set which is a large unweighted cyclic graph The cycles occur in loops of about 5-6 paths. It consists of about 8000 nodes and each node has from 1-6 (usually about 4-5) connections. I'm doing single pair shortest path calculations and have implemented the following code to do a breadth-first search. from Queue import Queue q = Queue() parent = {} fromNode = 'E1123' toNode = 'A3455' # path finding q.put(fromNode) parent[fromNode] = 'Root' while not q.empty(): # get the next node

Do invariant assertions fit into C# programming?

社会主义新天地 提交于 2019-12-04 12:29:54
问题 In the book coders at work, the author asks "How do you use invariants in your code". Please explain what this question means. I saw class invariants on wiki, but the example is in Java and I am not skilled enough in Java to relate this example to C#. .NET 4.0 introduces invariance, covariance, and contravariance and is well explained here. Invariance is so broad. The authors usage of the word seems unit test related. For those that read the book, what does the author mean? Are we talking

Why do we need different CPU architecture for server & mini/mainframe & mixed-core? [closed]

房东的猫 提交于 2019-12-04 12:03:52
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I was just wondering what other CPU architectures are available other than INTEL & AMD. So, found List of CPU architectures on

Evolutionary Algorithms: Optimal Repopulation Breakdowns

只谈情不闲聊 提交于 2019-12-04 11:56:24
问题 It's really all in the title, but here's a breakdown for anyone who is interested in Evolutionary Algorithms: In an EA, the basic premise is that you randomly generate a certain number of organisms (which are really just sets of parameters), run them against a problem, and then let the top performers survive. You then repopulate with a combination of crossbreeds of the survivors, mutations of the survivors, and also a certain number of new random organisms. Do that several thousand times, and

Is the heartbleed bug a manifestation of the classic buffer overflow exploit in C?

南笙酒味 提交于 2019-12-04 09:23:42
问题 In one of our first CS lectures on security we were walked through C's issue with not checking alleged buffer lengths and some examples of the different ways in which this vulnerability could be exploited. In this case, it looks like it was a case of a malicious read operation, where the application just read out however many bytes of memory Am I correct in asserting that the Heartbleed bug is a manifestation of the C buffer length checking issue? Why didn't the malicious use cause a

Difference between Discrete Structures and Discrete Mathematics

非 Y 不嫁゛ 提交于 2019-12-04 09:19:10
问题 I haven't yet found a good answer. Or any answer, for that matter. I've been asked to teach a discrete structures for CS course, but at the same time make sure it's not a discrete mathematics course -- that's offered by the Mathematics department. Many colleges offer a discrete structures course. There are also many DS textbooks. But when I look at the course syllabi and the textbook introductions, the term "discrete structures" is never used; they use "discrete mathematics" instead. DS only

Is it possible to evaluate lambda calculus terms efficiently?

此生再无相见时 提交于 2019-12-04 08:29:51
问题 I've been writing a lot of programs in the lambda calculus recently and I wish I could run some of them in realtime. Yet, as much as the trending functional paradigm is based on the lambda calculus and the rule of B-reductions, I couldn't find a single evaluator that isn't a toy, not meant for efficiency. Functional languages are supposed to be fast, but those I know don't actually provide access to normal forms (see Haskell's lazy evaluator, Scheme's closures and so on), so don't work as LC

Find the words in a long stream of characters. Auto-tokenize

岁酱吖の 提交于 2019-12-04 08:28:39
问题 How would you find the correct words in a long stream of characters? Input : "The revised report onthesyntactictheoriesofsequentialcontrolandstate" Google's Output: "The revised report on syntactic theories sequential controlandstate" (which is close enough considering the time that they produced the output) How do you think Google does it? How would you increase the accuracy? 回答1: I would try a recursive algorithm like this: Try inserting a space at each position. If the left part is a word,

Real-world use of binding objects in ruby

那年仲夏 提交于 2019-12-04 07:52:33
Last night, I was thinking about what i think are advanced ruby language features, namely Continuations (callcc) and Binding objects. I mean advanced because I have a statically-typed oo langages background (C#, Java, C++), I discovered ruby very recently, so these language features are not very familiar to me. I'm wondering what could be real-world use of these langages features. In my experience, everything could be done with statically typed oo langages, but I agree not very smartly sometimes. I think I figured out the beauty/interest of Continuation reading that nice article from Sam Ruby