computer-science

What exactly is the halting problem?

痞子三分冷 提交于 2019-11-26 07:25:17
问题 Whenever people ask about the halting problem as it pertains to programming, people respond with \"If you just add one loop, you\'ve got the halting program and therefore you can\'t automate task \" Makes sense. If your program has an infinite loop, then when your program is running, you have no way of knowing whether the program is still crunching input, or if it is just looping infinitely. But some of this seems counter intuitive. What if I was writing a halting problem solver, which takes

What is “entropy and information gain”?

时间秒杀一切 提交于 2019-11-26 06:09:18
问题 I am reading this book (NLTK) and it is confusing. Entropy is defined as: Entropy is the sum of the probability of each label times the log probability of that same label How can I apply entropy and maximum entropy in terms of text mining? Can someone give me a easy, simple example (visual)? 回答1: I assume entropy was mentioned in the context of building decision trees. To illustrate, imagine the task of learning to classify first-names into male/female groups. That is given a list of names

What is referential transparency?

这一生的挚爱 提交于 2019-11-26 04:56:38
问题 What does the term referential transparency mean? I\'ve heard it described as \"it means you can replace equals with equals\" but this seems like an inadequate explanation. 回答1: The term "referential transparency" comes from analytical philosophy, the branch of philosophy that analyzes natural language constructs, statements and arguments based on the methods of logic and mathematics. In other words, it is the closest subject outside computer science to what we call programming language

What is Type-safe?

て烟熏妆下的殇ゞ 提交于 2019-11-26 02:26:27
问题 What does \"type-safe\" mean? 回答1: Type safety means that the compiler will validate types while compiling, and throw an error if you try to assign the wrong type to a variable. Some simple examples: // Fails, Trying to put an integer in a string String one = 1; // Also fails. int foo = "bar"; This also applies to method arguments, since you are passing explicit types to them: int AddTwoNumbers(int a, int b) { return a + b; } If I tried to call that using: int Sum = AddTwoNumbers(5, "5"); The

What is a Y-combinator? [closed]

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 02:25:49
问题 A Y-combinator is a computer science concept from the “functional” side of things. Most programmers don\'t know much at all about combinators, if they\'ve even heard about them. What is a Y-combinator? How do combinators work? What are they good for? Are they useful in procedural languages? 回答1: If you're ready for a long read, Mike Vanier has a great explanation. Long story short, it allows you to implement recursion in a language that doesn't necessarily support it natively. 回答2: A Y

What are the differences between NP, NP-Complete and NP-Hard?

倖福魔咒の 提交于 2019-11-26 02:18:31
What are the differences between NP , NP-Complete and NP-Hard ? I am aware of many resources all over the web. I'd like to read your explanations, and the reason is they might be different from what's out there, or there is something that I'm not aware of. jason I assume that you are looking for intuitive definitions, since the technical definitions require quite some time to understand. First of all, let's remember a preliminary needed concept to understand those definitions. Decision problem : A problem with a yes or no answer. Now, let us define those complexity classes . P P is a

What are the differences between NP, NP-Complete and NP-Hard?

纵饮孤独 提交于 2019-11-26 01:50:03
问题 What are the differences between NP , NP-Complete and NP-Hard ? I am aware of many resources all over the web. I\'d like to read your explanations, and the reason is they might be different from what\'s out there, or there is something that I\'m not aware of. 回答1: I assume that you are looking for intuitive definitions, since the technical definitions require quite some time to understand. First of all, let's remember a preliminary needed concept to understand those definitions. Decision

What exactly does big Ө notation represent?

寵の児 提交于 2019-11-26 00:18:44
问题 I\'m really confused about the differences between big O, big Omega, and big Theta notation. I understand that big O is the upper bound and big Omega is the lower bound, but what exactly does big Ө (theta) represent? I have read that it means tight bound , but what does that mean? 回答1: It means that the algorithm is both big-O and big-Omega in the given function. For example, if it is Ө(n) , then there is some constant k , such that your function (run-time, whatever), is larger than n*k for

How to determine the longest increasing subsequence using dynamic programming?

落爺英雄遲暮 提交于 2019-11-26 00:13:31
问题 I have a set of integers. I want to find the longest increasing subsequence of that set using dynamic programming. 回答1: OK, I will describe first the simplest solution which is O(N^2), where N is the size of the collection. There also exists a O(N log N) solution, which I will describe also. Look here for it at the section Efficient algorithms. I will assume the indices of the array are from 0 to N - 1. So let's define DP[i] to be the length of the LIS (Longest increasing subsequence) which

What is a 'Closure'?

泄露秘密 提交于 2019-11-25 23:35:36
问题 I asked a question about Currying and closures were mentioned. What is a closure? How does it relate to currying? 回答1: Variable scope When you declare a local variable, that variable has a scope. Generally, local variables exist only within the block or function in which you declare them. function() { var a = 1; console.log(a); // works } console.log(a); // fails If I try to access a local variable, most languages will look for it in the current scope, then up through the parent scopes until