computer-science

What is recursion and when should I use it?

一笑奈何 提交于 2019-11-25 23:10:39
问题 One of the topics that seems to come up regularly on mailing lists and online discussions is the merits (or lack thereof) of doing a Computer Science Degree. An argument that seems to come up time and again for the negative party is that they have been coding for some number of years and they have never used recursion. So the question is: What is recursion? When would I use recursion? Why don\'t people use recursion? 回答1: There are a number of good explanations of recursion in this thread,

Normalization in DOM parsing with java - how does it work?

放肆的年华 提交于 2019-11-25 23:03:14
问题 I saw the line below in code for a DOM parser at this tutorial. doc.getDocumentElement().normalize(); Why do we do this normalization ? I read the docs but I could not understand a word. Puts all Text nodes in the full depth of the sub-tree underneath this Node Okay, then can someone show me (preferably with a picture) what this tree looks like ? Can anyone explain me why normalization is needed? What happens if we don\'t normalize ? 回答1: The rest of the sentence is: where only structure (e.g

What is polymorphism, what is it for, and how is it used?

对着背影说爱祢 提交于 2019-11-25 22:56:19
问题 What is polymorphism, what is it for, and how is it used? 回答1: If you think about the Greek roots of the term, it should become obvious. Poly = many: polygon = many-sided, polystyrene = many styrenes (a) , polyglot = many languages, and so on. Morph = change or form: morphology = study of biological form, Morpheus = the Greek god of dreams able to take any form. So polymorphism is the ability (in programming) to present the same interface for differing underlying forms (data types). For

What is the difference between statically typed and dynamically typed languages?

我是研究僧i 提交于 2019-11-25 22:29:15
问题 I hear a lot that new programming languages are dynamically typed but what does it actually mean when we say a language is dynamically typed vs. statically typed? 回答1: Statically typed languages A language is statically typed if the type of a variable is known at compile time. For some languages this means that you as the programmer must specify what type each variable is (e.g.: Java, C, C++); other languages offer some form of type inference , the capability of the type system to deduce the

Way to go from recursion to iteration

£可爱£侵袭症+ 提交于 2019-11-25 22:18:46
问题 I\'ve used recursion quite a lot on my many years of programming to solve simple problems, but I\'m fully aware that sometimes you need iteration due to memory/speed problems. So, sometime in the very far past I went to try and find if there existed any \"pattern\" or text-book way of transforming a common recursion approach to iteration and found nothing. Or at least nothing that I can remember it would help. Are there general rules? Is there a \"pattern\"? 回答1: Usually, I replace a

What is “2's Complement”?

≯℡__Kan透↙ 提交于 2019-11-25 21:43:13
问题 I\'m in a computer systems course and have been struggling , in part, with Two\'s Complement. I want to understand it but everything I\'ve read hasn\'t brought the picture together for me. I\'ve read the wikipedia article and various other articles, including my text book. Hence, I wanted to start this community wiki post to define what Two\'s Complement is, how to use it and how it can affect numbers during operations like casts (from signed to unsigned and vice versa), bit-wise operations

What is a plain English explanation of “Big O” notation?

落花浮王杯 提交于 2019-11-25 21:34:02
问题 I\'d prefer as little formal definition as possible and simple mathematics. 回答1: Quick note, this is almost certainly confusing Big O notation (which is an upper bound) with Theta notation "Θ" (which is a two-side bound). In my experience, this is actually typical of discussions in non-academic settings. Apologies for any confusion caused. Big O complexity can be visualized with this graph: The simplest definition I can give for Big-O notation is this: Big-O notation is a relative