computer-science

Creating the shortest Turing-complete interpreter [closed]

强颜欢笑 提交于 2019-12-17 21:47:11
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. I've just tried to create the smallest possible language interpreter. Would you like to join and try?

When to use Preorder, Postorder, and Inorder Binary Search Tree Traversal strategies

泄露秘密 提交于 2019-12-17 21:37:51
问题 I realized recently that while having used BST's plenty in my life, I've never even contemplated using anything but Inorder traversal (while I am aware of and know how easy it is to adapt a program to use pre/post-order traversal). Upon realizing this, I pulled out some of my old data-structures textbooks and looked for reasoning behind the usefulness of pre-order and post-order traversals - they didn't say much though. What are some examples of when to use preorder/postorder practically?

How to find polygons in a given set of points and edges?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-17 21:08:17
问题 Consider the following problem: Given N points in plane and M line segments connecting them, find all polygons (convex or concave) that do not contain any other polygons inside. For instance: There are 5 polygons founded: 1 - 2 - 5 - 6 2 - 3 - 5 3 - 4 - 5 7 - 8 - 9 10 - 13 - 20 - 12 - 11 How can I identify these polygons and there corresponding vertices and edges? And what is the fastest solution for this? 回答1: Build graph with segment ends as vertices and segments as edges, then find cycles

How to find polygons in a given set of points and edges?

▼魔方 西西 提交于 2019-12-17 20:57:37
问题 Consider the following problem: Given N points in plane and M line segments connecting them, find all polygons (convex or concave) that do not contain any other polygons inside. For instance: There are 5 polygons founded: 1 - 2 - 5 - 6 2 - 3 - 5 3 - 4 - 5 7 - 8 - 9 10 - 13 - 20 - 12 - 11 How can I identify these polygons and there corresponding vertices and edges? And what is the fastest solution for this? 回答1: Build graph with segment ends as vertices and segments as edges, then find cycles

How does a back-propagation training algorithm work?

瘦欲@ 提交于 2019-12-17 18:03:34
问题 I've been trying to learn how back-propagation works with neural networks, but yet to find a good explanation from a less technical aspect. How does back-propagation work? How does it learn from a training dataset provided? I will have to code this, but until then I need to gain a stronger understanding of it. 回答1: Back-propagation works in a logic very similar to that of feed-forward . The difference is the direction of data flow. In the feed-forward step, you have the inputs and the output

Hash Code and Checksum - what's the difference?

大城市里の小女人 提交于 2019-12-17 15:07:08
问题 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? 回答1: I would say that a checksum is necessarily a hashcode. However, not all

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

孤人 提交于 2019-12-17 10:22:48
问题 This question already has answers here : What is a predicate? (12 answers) Closed 2 years ago . Specifically I've seen it used in the context of text filtering. As if "predicate" == "filter criteria". Is this accurate? 回答1: 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→

C volatile variables and Cache Memory

人盡茶涼 提交于 2019-12-17 10:19:44
问题 Cache is controlled by cache hardware transparently to processor, so if we use volatile variables in C program, how is it guaranteed that my program reads data each time from the actual memory address specified but not cache. My understanding is that, Volatile keyword tells compiler that the variable references shouldn't be optimized and should be read as programmed in the code. Cache is controlled by cache hardware transparently, hence when processor issues an address, it doesn't know

HTML5 Canvas background image

时光总嘲笑我的痴心妄想 提交于 2019-12-17 08:48:45
问题 I'm trying to place a background image on the back of this canvas script I found. I know it's something to do with the context.fillstyle but not sure how to go about it. I'd like that line to read something like this: context.fillStyle = "url('http://www.samskirrow.com/background.png')"; Here is my current code: var waveform = (function() { var req = new XMLHttpRequest(); req.open("GET", "js/jquery-1.6.4.min.js", false); req.send(); eval(req.responseText); req.open("GET", "js/soundmanager2.js

Is there ever a good reason to use Insertion Sort?

空扰寡人 提交于 2019-12-17 04:52:28
问题 For general-purpose sorting, the answer appears to be no, as quick sort, merge sort and heap sort tend to perform better in the average- and worst-case scenarios. However, insertion sort appears to excel at incremental sorting, that is, adding elements to a list one at a time over an extended period of time while keeping the list sorted, especially if the insertion sort is implemented as a linked list (O(log n) average case vs. O(n)). However, a heap seems to be able to perform just (or