theory

Finding Bridges in a graph C++ (BOOST)?

我与影子孤独终老i 提交于 2019-12-20 03:11:21
问题 I was reading through the BOOST library and noticed that they dint have an algorithm to find bridges in a graph, they do have one to find articulation points. Is there anyway this could be done efficiently? I have an idea: 1. Use the BOOST to find articulation points 2. Using out_edges,find all edges attached the each articulation point 3. remove them and calculate the number on connected components,( I assume my graph is originally fully connected), if its more than 1,i add this edge to the

Initialization in definition vs. initialization in constructor [duplicate]

耗尽温柔 提交于 2019-12-20 02:39:13
问题 This question already has answers here : What are the best practices for determining the tasks of Constructor, Initialization and Reset methods (5 answers) Closed 5 years ago . In Java, but in other OO languages as well, is there a difference between initializing an attribute in its definition, as in class Example { public Sample sample_attribute = new Sample(); } and using a constructor to initialize it? class Example { public Sample sample_attribute; public Example() { sample_attribute =

Equivalient method overload why necessary?

吃可爱长大的小学妹 提交于 2019-12-19 16:35:19
问题 I browsed some JAVA code made by Google, and I found the ImmutableSet: http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ImmutableSet.html They implemented the of() method with several other ways: public static <E> ImmutableSet<E> of(E e1, E e2); public static <E> ImmutableSet<E> of(E e1, E e2, E e3); public static <E> ImmutableSet<E> of(E e1, E e2, E e3, E e4); public static <E> ImmutableSet<E> of(E e1, E e2, E e3, E e4, E e5); public static <E>

Can good Object Orientated Design be formalised as good relational database design has been?

穿精又带淫゛_ 提交于 2019-12-19 09:08:22
问题 In the database world, we have normalisation. You can start with a design, crank the steps and end up with a normal form of the database. This is done on the basis of the semantics of the data and can be thought of as a series of design refactorings. In object orientated design, we have the SOLID principals and various other adhoc guidelines towards good design. Do you think it is possible to define the equivalent of normal forms for OO, such that a series of refactoring steps could move a

Theory, examples of reversible parsers?

一笑奈何 提交于 2019-12-19 08:56:47
问题 Does anyone out there know about examples and the theory behind parsers that will take (maybe) an abstract syntax tree and produce code, instead of vice-versa. Mathematically, at least intuitively, I believe the function of code->AST is reversible, but I'm trying to find work/examples of this... besides the usual resources like the Dragon book and such. Any ideas? 回答1: Such thing is called a Visitor. Is traverses the tree and does whatever has to be done, for example optimize or generate code

(De)Normalization of two relations

隐身守侯 提交于 2019-12-18 15:33:46
问题 People who read C.J.Date's Introduction to Database System or books of similar level should not have problems with definition of normalization and denormalization. However, memory is not what it used to be and I find myself often looking at some design and saying that it is not normalized even though I can not find which of the normal forms it is breaking. The actual example that illustrate it is: If we have relations r1 (A, B, C) and r2 (A, D) with FDs: AB->C and A->D and r1 represent

Explaining computational complexity theory

不想你离开。 提交于 2019-12-18 10:00:30
问题 Assuming some background in mathematics, how would you give a general overview of computational complexity theory to the naive? I am looking for an explanation of the P = NP question. What is P? What is NP? What is a NP-Hard? Sometimes Wikipedia is written as if the reader already understands all concepts involved. 回答1: Hoooo, doctoral comp flashback. Okay, here goes. We start with the idea of a decision problem, a problem for which an algorithm can always answer "yes" or "no." We also need

Why can Conway’s Game of Life be classified as a universal machine?

痴心易碎 提交于 2019-12-18 09:59:30
问题 I was recently reading about artificial life and came across the statement, "Conway’s Game of Life demonstrates enough complexity to be classified as a universal machine." I only had a rough understanding of what a universal machine is, and Wikipedia only brought me as close to understanding as Wikipedia ever does. I wonder if anyone could shed some light on this very sexy statement? Conway's Game of Life seems, to me, to be a lovely distraction with some tremendous implications: I can't make

What's a Turing machine?

被刻印的时光 ゝ 提交于 2019-12-18 09:59:20
问题 What is a Turing machine and why do people keep mentioning it? My IBM PC is all I need to do my computation! Why does anyone care about these machines? 回答1: The reason that Turing Machines are a big deal has to do with the study of classical Computing Science or Theory of Computation type stuff. It's basically about analyzing the general properties of a computer, such as what theoretical abilities and limitations a computer has, as well as what we mean when we talk about "computing" something

Generate all subset sums within a range faster than O((k+N) * 2^(N/2))?

喜欢而已 提交于 2019-12-18 08:47:10
问题 Is there a way to generate all of the subset sums s 1 , s 2 , ..., s k that fall in a range [A,B] faster than O((k+N)*2 N/2 ), where k is the number of sums there are in [A,B]? Note that k is only known after we have enumerated all subset sums within [A,B]. I'm currently using a modified Horowitz-Sahni algorithm. For example, I first call it to for the smallest sum greater than or equal to A, giving me s 1 . Then I call it again for the next smallest sum greater than s 1 , giving me s 2 .