theory

Big-O for Eight Year Olds? [duplicate]

六月ゝ 毕业季﹏ 提交于 2019-12-16 22:21:35
问题 This question already has answers here : What is a plain English explanation of “Big O” notation? (39 answers) Closed 2 years ago . I'm asking more about what this means to my code. I understand the concepts mathematically, I just have a hard time wrapping my head around what they mean conceptually. For example, if one were to perform an O(1) operation on a data structure, I understand that the number of operations it has to perform won't grow because there are more items. And an O(n)

Big-O for Eight Year Olds? [duplicate]

时光毁灭记忆、已成空白 提交于 2019-12-16 22:21:34
问题 This question already has answers here : What is a plain English explanation of “Big O” notation? (39 answers) Closed 2 years ago . I'm asking more about what this means to my code. I understand the concepts mathematically, I just have a hard time wrapping my head around what they mean conceptually. For example, if one were to perform an O(1) operation on a data structure, I understand that the number of operations it has to perform won't grow because there are more items. And an O(n)

What is a lambda (function)?

坚强是说给别人听的谎言 提交于 2019-12-16 19:56:29
问题 For a person without a comp-sci background, what is a lambda in the world of Computer Science? 回答1: Lambda comes from the Lambda Calculus and refers to anonymous functions in programming. Why is this cool? It allows you to write quick throw away functions without naming them. It also provides a nice way to write closures. With that power you can do things like this. Python def adder(x): return lambda y: x + y add5 = adder(5) add5(1) 6 As you can see from the snippet of Python, the function

Biggest diameter of a set with a distance function

老子叫甜甜 提交于 2019-12-13 20:06:21
问题 I have a set of elements with a distance function between elements satisfying the triangle inequality. I want to find the pair of elements separated by the greatest distance. Is there any known solution better than trying all pairs? 回答1: If you measure the distance from point a to points b, c and d, and you find that |ab| + |ac| < |ad|, then you know that |bc| is shorter than |ad|, and there's no need to measure |bc|. So not all pairs need to be checked to find the longest distance. A

what is a programming language?

ⅰ亾dé卋堺 提交于 2019-12-13 14:42:41
问题 Wikipedia says: A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer. Programming languages can be used to create programs that specify the behavior of a machine, to express algorithms precisely, or as a mode of human communication. But is this true? It occurred to me in the shower this morning that a programming language might just be a set of conventions, something that both a human and

Finding a language that is not LL(1)?

亡梦爱人 提交于 2019-12-13 13:05:59
问题 I've been playing around with a lot of grammars that are not LL(1) recently, and many of them can be transformed into grammars that are LL(1). However, I have never seen an example of an unambiguous language that is not LL(1). In other words, a language for which any unambiguous grammar for the language is not LL(1)), nor do I have any idea how I would go about proving that I had found one if I accidentally stumbled across one. Does anyone know how to prove that a particular unambiguous

Pros and Cons explicitly setting enum field's values

巧了我就是萌 提交于 2019-12-13 12:54:41
问题 Is it preferable to explicitly set enum's fields instead of just defining their names? E.g. any pros and cons for Enum1 vs Enum2? Enum1: enum SomeEnum { Something1 = 0, Something2 = 1 } Enum2: enum SomeEnum { Something1, Something2 } P.S. This question doesn't relates to enums that would be stored in database, which is requires to set values explicitly. Edit: Say all values are 0, 1, etc... They are not negative or something. 回答1: Enum1 and Enum2 compile to the same enumeration. So from a

USACO: Subsets (Inefficient)

一个人想着一个人 提交于 2019-12-13 09:19:26
问题 I am trying to solve subsets from the USACO training gateway... Problem Statement For many sets of consecutive integers from 1 through N (1 <= N <= 39), one can partition the set into two sets whose sums are identical. For example, if N=3, one can partition the set {1, 2, 3} in one way so that the sums of both subsets are identical: {3} and {1,2} This counts as a single partitioning (i.e., reversing the order counts as the same partitioning and thus does not increase the count of partitions).

SQL: Where should the Primary Key be defined

守給你的承諾、 提交于 2019-12-13 03:39:56
问题 I'm creating a database with several sql files 1 file creates the tables. 1 file adds constraints. 1 file drops constraints. The primary is a constraint however I've been told by someone to define your primary key in the table definition but not given a reason why. Is it better to define the primary key as a constraint that can be added and dropped or is it better to do it in the table definition. My current thinking is to do it in the table definition because doing it as a removable

Database Design for One to One relationships

丶灬走出姿态 提交于 2019-12-12 18:15:05
问题 I'm trying to finalize my design of the data model for my project, and am having difficulty figuring out which way to go with it. I have a table of users, and an undetermined number of attributes that apply to that user. The attributes are in almost every case optional, so null values are allowed. Each of these attributes are one to one for the user. Should I put them on the same table, and keep adding columns when attributes are added (making the user table quite wide), or should I put each