instruction
stringlengths
0
29.8k
⌀
Distribute n objects in a cube so that they have max distance between each other
|algorithms|computational-geometry|
here is a half-baked answer: I know that Ugo Dal Lago at University of Bologna has been studying quantum lambda calculus. You may want to check [his publications][1] and perhaps this one in particular: [Quantum implicit computational complexity][2] by U. Dal Lago, A. Masini, M. Zorzi. I am saying it's a half-bak...
|algorithms|probability-theory|randomized-algorithms|
I'm trying to use a color camera to track multiple objects in space. Each object will have a different color and in order to be able to distinguish well between each objects I'm trying to make sure that each color assigned to an object is as different from any color on any other object as possible. In RGB space, we ...
|algorithms|optimization|computational-geometry|
null
I'm trying to figure out a way I could represent a Facebook user as a vector. I decided to go with stacking the different attributes/parameters of the user into one big vector (i.e. age is a vector of size 100, where 100 is the maximum age you can have, if you are lets say 50, the first 50 values of the vector would be...
How to representat the interests of a Facebook user
How to represent the interests of a Facebook user
There are some documents to be indexed, that means I need to read the docs and extract the words and index them by storing at which document they appear and at which position. For each word initially I am creating a separate file. Consider 2 documents: * document 1: “The Problem of Programming Communication with...
|data-structures|binary-trees|storage|
> if I change a single index the whole file will need to be rewritten So don't change indices. When you add data, remember what words already existed, and store subsequent words afterward. For each word, instead of storing one index in the index file, store several. There is a lot to optimize on top of that. But ...
As explained by Guillaume13, Vector is deprecated and therefore the usage should be discouraged. There is the ArrayList class though, which basically does the same but is more up to date in the Java world. Considering your the actual question, I think both answers are more or less equally good, as the term "extend" ...
null
I guess you misunderstood the actual goal of your course, as good C++ (basically) uses the abstractions provided by the standard library (why would you want to reinvent the wheel?). There is even a quote by Stroustrup saying ["keep arrays out of interfaces"][1] in his FAQ where he gives some hints how to write safe...
Ummmm... isn't the point of a circular array to wrap around and store some of the data at the beginning? Isn't it just to simply overlap data to fill in bits not already filled, but can be filtered out by using the % operator? Or am I completely wrong?
Thread a binary search tree into an array, and use certain techniques to keep the rotations in $\mathcal{O}(1)$. Insertions will still take $\mathcal{O}(log\text{ }n)$, but get-min and extract-min will be in $\mathcal{O}(1)$ without having to invent a new structure like [Raphael][1] is [attempting][2] to do. On h...
null
For a CS student, the professor may discourage std::string and ask for char array, so as to teach basics of array. In my school, the teacher asked us to write C routines like `strlen`, `strcmp` etc. on our own. It can't get any low level then this (leaving assembly!). By using array, instead of string, you can lear...
On my old 256MB RAM, pc I get this message. (I guess it is quite common) > **Windows - Virtual Memory minimum too low** > Your system is low on virtual memory. Windows is increasing the size of your virtual memory paging file. During this process, memory requests for some applications may be denied. ... Please...
How to interpret "Windows - Virtual Memory minimum too low" from a CS student point of view?
|operating-systems|
null
A computer typically has vastly more hard disk space that RAM. To compensate for limitations in the size of RAM, the operating system reserves part of the disk to use as additional RAM. This is called _virtual memory_. The RAM and the virtual memory are then divided into even chunks called pages. From the programmer's ...
Koenig and Moe's _Accelerated C++_ and Stroustrup's _Programming: Principles and Practice Using C++_ are using std::string and other components from the standard library from the start. If I remember correctly, they don't even present C arrays for Koenig and Moe and Stroustrup does it quite late in the book (perhaps ev...
null
ArrayOfLongestLists bufferList for i = listlenght - 1 to -1 step -1 clear bufferList add list[i] to bufferList for j = i-1 to -1 step -1 if list[j] < lastElementof bufferList add list[j] to bufferList endif endfor if lengthOf Arra...
All colors will be on the surface of the RGB cube, unless I'm mistaken, for the same reason that all electrical charge appears on the surface of electrical conductors. This suggests the following method to determine colors: - interpret the RGB color space as an XYZ Cartesian space; - interpret candidate colors as c...
Text *is* visual. We use all kinds of visual cues in our code. Every use of whitespace (indents, new lines, blank lines, intraline spacing) is directed towards providing visual cues for the functionality of the code. We use all kinds of different syntax to provide visual information on what code is doing. Our editor...
All colors will be on the surface of the RGB cube, unless I'm mistaken, for the same reason that all electrical charge appears on the surface of electrical conductors. This suggests the following method to determine colors: - interpret the RGB color space as an XYZ Cartesian space; - interpret candidate colors as c...
There are many methods to prove that [a language is not regular](http://cs.stackexchange.com/q/1031/157), but what do I need to do to prove that some language *is* regular? Specifically, if I am given that $L$ is regular, how can I prove that the following $L'$ is regular, too? $\qquad \displaystyle L' := \{w...
How to prove a language is regular?
Why are blocking artifacts serious when there is fast motion in MPEG? Here is the guess I made: In MPEG, each block in an encoding frame is matched with a block in the reference frame. If the difference of two blocks is small, only the difference is encoded using DCT. Is the reason blocking artifacts are serious...
Why are blocking artifacts serious when there is fast motion in MPEG?
|data-compression|
In my computability class we were given a practice final to go over and i'm really struggling with one of the questions on it. Prove the following statement: If $L_1$ is a regular language, then so is $L_2 = \{ uv |$ $u$ is in $L_1$ or $v$ is in $L_1 \}$. You can't use the pumping lemma for regular language...
Proving a language is regular/nonregular
|untagged|
ArrayOfLongestLists bufferList for i = listlenght - 1 to -1 step -1 clear bufferList add list[i] to bufferList for j = i-1 to -1 step -1 if list[j] < lastElementof bufferList add list[j] to bufferList endif endfor if lengthOf Arra...
|formal-languages|regular-languages|
|information-theory|data-compression|video|
In my computability class we were given a practice final to go over and I'm really struggling with one of the questions on it. > Prove the following statement: > If $L_1$ is a regular language, then so is > $L_2 = \{ uv |$ $u$ is in $L_1$ or $v$ is in $L_1 \}$. You can't use the pumping lemma for regular la...
|formal-languages|regular-languages|
null
-a recursive helper function list form_longest_sublist_from(list array,list buffer,from) add array[from] to buffer list ret as copy of buffer from i = from - 1 to -1 step -1 if last buffer > array[...
I was recently reading about algorithms for checking bisimilarity and read that the problem is [P-complete](http://en.wikipedia.org/wiki/P-complete). Furthermore, a consequence of this is that this problem, or any P-complete problem, is unlikely to have an efficient parallel algorithms. > What is the intuition behin...
P-Completeness and Parallel Computation
|complexity-theory|
Because "efficient parallel" falls inside [$\mathsf{NC}$][1] and it is widely believed that $\mathsf{NC} \neq \mathsf{P}$. So any $\mathsf{P\text{-}complete}$ problem is not believed to have an efficient parallel algorithm. [1]: http://qwiki.stanford.edu/index.php/Complexity_Zoo:N#nc
|complexity-theory|parallel-computing|
Because "efficient parallel" falls inside [$\mathsf{NC}$](http://en.wikipedia.org/wiki/NC_%28complexity%29) (“Nick's Class” of problems decidable in polylogarithmic time with a polynomial number of processors), and it is widely believed that [$\mathsf{NC} \neq \mathsf{P}$](http://en.wikipedia.org/wiki/NC_%28complexity%...
Because "efficient parallel" falls inside [$\mathsf{NC}$][1] (“Nick's Class” of problems decidable in polylogarithmic time with a polynomial number of processors), and it is widely *believed* that [$\mathsf{NC} \neq \mathsf{P}$][2]. So any $\mathsf{P\text{-}complete}$ problem is not *believed* to have an efficient para...
Kaveh's answer covers the usual definition of "parallelism", which is NC. The question of whether P $<$ NC is one of the harder questions in complexity theory (and in some ways just as relevant as the P $<$ NP question). The intuition behind it is that some problems in P, like linear programming, or DFS order feel ...
So we are covering recursion in a C++ class I am taking. I understand what it is, a function that calls itself (a very basic explanation), I am just having trouble coming up with a lot of instances where doing that would be useful. It seems to me like it would be a very situational thing to use, but the way my instru...
C++ Recursion, When to use?
|recursion|
There is another [question][1] about proving that languages are not regular. My [personal favorite][2] way to do it is, essentially, equivalent to the [Myhill-Nerode Theorem][3]. For proving that a language is regular, you can either [show it is expressible by a DFA, NFA, Regular Expression, etc.][4] or you can use...
You can use the pumping lemma to show that a language is *not* regular. Here, you're trying to prove that if $L_1$ is regular then $L_2$ is regular. The pumping lemma can't be used to prove this implication. It could be used to prove the contraposite (i.e. you might be able to prove that if $L_2$ is not regular, then $...
|algorithms|recursion|
The solutions to some problems are more naturally expressed unsigned recursion. For example, assume that you have a tree data structure with two kinds of node types: leaves, which store an integer value; and branches, which have a left and right subtree in their fields. Assume that the leaves are ordered, so that th...
Basic Recursion, When to use?
The solutions to some problems are more naturally expressed unsigned recursion. For example, assume that you have a tree data structure with two kinds of node types: leaves, which store an integer value; and branches, which have a left and right subtree in their fields. Assume that the leaves are ordered, so that th...
There is another [question][1] about proving that languages are not regular. My [personal favorite][2] way to do it is, essentially, equivalent to the [Myhill-Nerode Theorem][3]. For proving that a language is regular, you can either [show it is expressible by a DFA, NFA, Regular Expression, etc.][4] or you can use...
So we are covering recursion in a C++ class I am taking. I understand what it is, a function that calls itself (a very basic explanation), I am just having trouble coming up with a lot of instances where doing that would be useful. It seems to me like it would be a very situational thing to use, but the way my instru...
Write $L_2$ as $$\{uv \mid u \in L_1\} \cup \{uv \mid v\in L_1\}$$ (convince yourself it is OK to do so) Then check about [right/left quotient](https://en.wikipedia.org/wiki/Right_quotient). With that, the proof is trivial.
Kaveh's answer covers the usual definition of "parallelism", which is NC. The question of whether P $<$ NC is one of the harder questions in complexity theory (and in some ways just as relevant as the P $<$ NP question). The intuition behind it is that some problems in P, like linear programming, or DFS order feel ...
You can use the pumping lemma to show that a language is *not* regular. Here, you're trying to prove that if $L_1$ is regular then $L_2$ is regular. The pumping lemma can't be used to prove this implication. It could be used to prove the contraposite (i.e. you might be able to prove that if $L_2$ is not regular, then $...
Write $L_2$ as $$\{uv \mid u \in L_1, v\in \Sigma^*\} \cup \{uv \mid u\in \Sigma^*, v\in L_1\}$$ (convince yourself it is OK to do so) Then check about [right/left quotient](https://en.wikipedia.org/wiki/Right_quotient). With that, the proof is trivial. EDIT: actually, quotient is not needed. Only concatenation...
From someone who practically lives in recursion I will try and shed some light on the subject. When first introduced to recursion you learn that it is a function that calls itself and is basically demonstrated with algorithms such as tree traversal. Later you find that it is used a lot in [functional programming][07...
Suppose I am given $n$ fixed width integers (i.e. they fit in a register of width $w$), $a_1, a_2, \dots a_n$ such that their sum $a_1 + a_2 + \dots + a_n = S$ also fits in a register of width $w$. It seems to me that we can always permute the numbers to $b_1, b_2, \dots b_n$ such that each prefix sum $S_i = b_1 + b...
Overflow safe summation
|algorithms|overflow|
|algorithms|arrays|integers|overflow|
The solutions to some problems are more naturally expressed unsigned recursion. For example, assume that you have a tree data structure with two kinds of node types: leaves, which store an integer value; and branches, which have a left and right subtree in their fields. Assume that the leaves are ordered, so that th...
From someone who practically lives in [recursion][12] I will try and shed some light on the subject. When first introduced to recursion you learn that it is a function that calls itself and is basically demonstrated with algorithms such as tree traversal. Later you find that it is used a lot in [functional programmi...
1. Partition $a_1, \ldots, a_n$ into a two lists, the positive elements (and zeros) and the negative elements, $P=p_1,\ldots,p_k$ and $M=m_1\ldots m_{n-k}$. 2. Let $S=p_1$. Remove $p_1$ from $P$. 3. While both lists are non-empty 4. If $S>0$ select the next element from $M$ and add it to $S$. Remove that element. 5...
The following linear-time algorithm adopts the strategy of hovering around $0$, by choosing either positive or negative numbers based on the sign of the partial sum. 1. Partition $a_1, \ldots, a_n$ into a two lists, the positive elements (and zeros) and the negative elements, $P=p_1,\ldots,p_k$ and $M=m_1\ldots m_{...
The following linear-time algorithm adopts the strategy of hovering around $0$, by choosing either positive or negative numbers based on the sign of the partial sum. It preprocesses the list of numbers; it computes the permutation of the input _on-the-fly_, while performing the addition. 1. Partition $a_1, \ldots, ...
Suppose I am given an array of $n$ fixed width integers (i.e. they fit in a register of width $w$), $a_1, a_2, \dots a_n$. I want to compute the sum $S = S_n$ on a machine with 2's complement arithmetic, performing additions modulo $2^w$ with wraparound semantics. That's easy — but the sum may overflow the register siz...
Detecting overflow in summation
|algorithms|arrays|integers|
The following linear-time algorithm adopts the strategy of hovering around $0$, by choosing either positive or negative numbers based on the sign of the partial sum. It preprocesses the list of numbers; it computes the permutation of the input _on-the-fly_, while performing the addition. 1. Partition $a_1, \ldots, ...
**Strategy** The following linear-time algorithm adopts the strategy of hovering around $0$, by choosing either positive or negative numbers based on the sign of the partial sum. It preprocesses the list of numbers; it computes the permutation of the input _on-the-fly_, while performing the addition. **Algorithm...
Let A and B be languages, such as A ⊆ B, and B is Turing-recognizable. A couldn't be Turing-recognizable? If so, is there any example?
Sub language is not Turing-recognizable, or could it be?
|turing-machines|
In this case A couldn't be Turing-recognizable. Take this as an example: language B is the union of a language t.r (C) and a language not t.r(A). you can create a turing machine that recognizes B. A is not t.r and A ⊆ B. is that right? i dont know if it is..so.. =)
The solutions to some problems are more naturally expressed using recursion. For example, assume that you have a tree data structure with two kinds of nodes: leaves, which store an integer value; and branches, which have a left and right subtree in their fields. Assume that the leaves are ordered, so that the lowest...
null
|algorithms|arrays|integers|numerical-analysis|
|algorithms|arrays|integers|overflow|numerical-analysis|
|computability|
This is something that confuses many students. The point here is that being subset of another language does imply much about the difficulty of their computation. You can always consider the trivial language $\emptyset$ and $\Sigma^*$ and any other language is between them w.r.t. set inclusion. Therefore just knowing...
This is something that confuses many students. The point here is that being subset of another language does not imply much about the difficulty of computation. You can always consider the trivial language $\emptyset$ and $\Sigma^*$ and any other language is between them w.r.t. set inclusion. Therefore just knowing t...
null
Any $P$-complete problem, is unlikely to have an efficient parallel algorithm. Why ? The existence of $P$-complete problems is the most important clue that $(P ∩ POLYLOGSPACE) ≠ P$. The question then is, why is this conjecture relevant to parallel computing? Let's start with the resources used in a computation. Fo...
Any $P$-complete problem, is unlikely to have an efficient parallel algorithm. Why ? The existence of $P$-complete problems is the most important clue that $(P ∩ POLYLOGSPACE) ≠ P$. The question then is, why is this conjecture relevant to parallel computing? Let's start with the resources used in a computation. Fo...