instruction
stringlengths
0
29.8k
⌀
Your two algorithms are equivalent (at least for positive integers, what happens with negative integers in the imperative version depends on Java's semantics for `%` which I don't know by heart). In the recursive version, let $a_i$ and $b_i$ be the argument of the $i$th recursive call: $$\begin{gather*} a_{i+1} = b...
DCT is both discrete and finite, it has a limited range in both the space and frequency domains. If the change in a certain location is large or the location changes a lot, the results of the transform will be beyond the sampling range in the frequency domain. Since as you mentioned MPEG is based on blocks, the resu...
|formal-languages|proof-techniques|context-free|pumping-lemma|
null
I have been reading policies for security I had this doubt. If anyone knows more about it do tell.
can Bell-LaPadula Model emulate the Chinese Wall model?
|information-theory|security|access-control|
I was given a problem to find the adversary arguments for finding the lower bounds for selection and insertion sort. But I couldn't find a reference to it anywhere. I have some doubts regarding this. I understand that adversary arguments are usually used for finding lower bounds for certain "problems" rather tha...
How to oracle and adversary arguments for slection and insertion sort
|algorithms|algorithm-analysis|
Some more options: If you're into Billiard, you can create [logic gates from Billiard balls](https://en.wikipedia.org/wiki/Billiard_ball_computer) If you prefer the wild life, [Crab-based logic gates](http://www.complex-systems.com/pdf/20-2-2.pdf) should fit.
null
I have been reading on security policies and the question wether [Bell-LaPadula](https://en.wikipedia.org/wiki/Bell-LaPadula_model) can be used to implement [Chinese Wall](https://en.wikipedia.org/wiki/Chinese_wall). Does anyone know more about it?
Can the Bell-LaPadula model emulate the Chinese Wall model?
I was asked to find the adversary arguments necessary for finding the lower bounds for selection and insertion sort. I could not find a reference to it anywhere. I have some doubts regarding this. I understand that adversary arguments are usually used for finding lower bounds for certain "problems" rather than "algo...
How to use adversary arguments for selection and insertion sort?
|algorithms|algorithm-analysis|proof-techniques|lower-bounds|
What you described sounds more like a [planning problem][1]. It sounds like what might be modeled with a planning language, such as [STRIPS][2], ADL, etc. [1]: http://en.wikipedia.org/wiki/Automated_planning [2]: http://en.wikipedia.org/wiki/STRIPS
What you described sounds more like a [planning problem][1] in AI. It sounds like what might be modeled with a planning language, such as [STRIPS][2], ADL, etc. Once modeled, the plan can then be solved by one of many planning algorithms/heuristics, which are typically state space search algorithms. The Wiki links shou...
I've been struggling with several Hamming code/error detection questions because the logic behind it doesn't seem to make sense. eg.1 ![enter image description here][1] eg.2 ![enter image description here][2] I don't really understand the above two examples and the calculations taking place. How were...
Encoding the sequence 0110 and determining parity, data bit and value
null
|coding-theory|
Well, this example are not easy to read, by they are indeed correct. **e.g.1**: The word to code has 4 bits $b_1 b_2 b_3 b_4$. To this we add 3 parity bits: $p_1 = b_1 +b_2 +b_3$, $p_2 = b_1 +b_2 +b_4$ and $p_3 = b_1 +b_3 +b_4$. Then we transmit the code word $$C= b_1 b_2 b_3 p_1 b_4 p_2 p_3$$ Why this orde...
What you described sounds more like a planning problem in AI. It sounds like what might be modeled with a planning language, such as [STRIPS][2], ADL, PDDL, etc. Once modeled, the plan can then be solved by one of many planning algorithms/heuristics, which are typically state space search algorithms. The Wiki links sho...
Well, these examples are not easy to read, by they are indeed correct. **e.g.1**: The word to code has 4 bits, and lets call them $b_1 b_2 b_3 b_4$. To this "data" word add 3 parity bits: * $p_1 = b_1 +b_2 +b_3$, * $p_2 = b_1 +b_2 +b_4$, and * $p_3 = b_1 +b_3 +b_4$. Then we transmit the code word...
null
Is there any algorithm that works better than $O(n^2)$ to verify whether a square matrix is a magic one? (E.g. such as sum of all the rows, cols and diagonally are equal to each other). I did see someone mention a $O(n)$ time on a website a few days ago but could not figure out how. Thanks in advance
Magic Square Check for NxN Matrix - with Minimum Complexity?
|complexity-measures|
null
I've been struggling with several Hamming code/error detection questions because the logic behind it doesn't seem to make sense. eg.1 ![enter image description here][1] eg.2 ![enter image description here][2] I don't really understand the above two examples and the calculations taking place. How were...
null
I've been struggling with several Hamming code/error detection questions because the logic behind it doesn't seem to make sense. eg.1 ![enter image description here][1] eg.2 ![enter image description here][2] I don't really understand the above two examples and the calculations taking place. How were...
If you have an $N \times N$ matrix, then it has $N^2$ entries, and as you need to check all entries at least once to see if the square is a magic square, any algorithm must have a running time of $\Omega(N^2)$. For a square to be a magic square, all rows, columns and both diagonals must sum to the same number. There...
The problem is in $\mathrm{P}$ if the number of items is constant. Let $K$ be the number of items (independent of $n$). For every ordering of items, use backtracking to try all allowed routes: you first go through some warehouse for the first item (trying all warehouses), then one for the second item and so on. T...
Among others, this problem can be seen as an instance of the Traveling Purchaser Problem. $\text{TPP}$ is a generalization of $\text{TSP}$ and was first proposed by T. Ramesh, Traveling purchaser problem, 1981. The problem is as follows: > We are given a set $M = \{ 1, ..., m \}$ of markets and a set of $N = \{ 1, ....
null
I have a logistic problem that can be seen as a variant of $\text{TSP}$. It is so natural, I'm sure it has been studied in Operations research or something similar. Here's one way of looking at the problem. I have $P$ warehouses on the Cartesian plane. There's a path from a warehouse to every other warehouse and the...
From your comment it seems you are confusing the meaning of lower bounds, upper bounds and asymptotic notation. For instance, take Insertion Sort. Its best-case running time is $\Omega(n)$ (this happens when the input is already sorted). Its worst-case running time is $O(n^2)$ (this happens when the input is reverse so...
Well, these examples are not easy to read, by they are indeed correct. **e.g.1**: The word to code has 4 bits, and lets call them $b_1 b_2 b_3 b_4$. To this "data" word add 3 parity bits (adding is over $GF(2)$): * $p_1 = b_1 \oplus b_2 \oplus b_3$, * $p_2 = b_1 \oplus b_2 \oplus b_4$, and * $p_3 ...
|algorithms|algorithm-analysis|
Is there any algorithm that works better than $\Theta(n^2)$ to verify whether a square matrix is a magic one? (E.g. such as sum of all the rows, cols and diagonally are equal to each other). I did see someone mention a $O(n)$ time on a website a few days ago but could not figure out how.
If you have an $N \times N$ matrix, then it has $N^2$ entries, and as you need to check all entries at least once to see if the square is a magic square, any algorithm must have a running time of $\Omega(N^2)$. For a square to be a magic square, all rows, columns and both diagonals must sum to the same number. There...
From your comment it seems you are confusing the meaning of lower bounds, upper bounds and asymptotic notation. For instance, take Insertion Sort. Its best-case running time is $\Theta(n)$ (this happens when the input is already sorted). Its worst-case running time is $\Theta(n^2)$ (this happens when the input is rever...
What you described sounds more like a planning problem in AI. It sounds like what might be modeled with a planning language, such as [STRIPS][1], ADL, PDDL, etc. Once modeled, the plan can then be solved by one of many planning algorithms/heuristics, which are typically state space search algorithms. The Wiki links sho...
Unfortunately I am still not so strong in understanding [Sweep Line Algorithm](http://en.wikipedia.org/wiki/Sweep_line_algorithm). All papers and textbooks on the topic are already read, however understanding is still far away. Just in order to make it clearer I try to solve as many exercises as I can. But, really inte...
Circle Intersection with Sweep Line Algorithm
|algorithms|computational-geometry|
I'm starting to study **non deterministic automatas** using the book of [Hopcroft][1]. I'm stuck in a problem that I found very interesting: > Give non deterministic finite automata accepting all the string that > have the same value when evaluated left to right as right to left by > multiplying according to the n...
State machine for strings that have the same value in a non associative multiplication
|nondeterminism|
|formal-languages|automata|nondeterminism|
You can add $n$ numbers of size $w$ without any overflow if you are using $\lceil \log n\rceil + w$ bits arithmetic. My suggestion is to do just that and then check if the result is in the range. Algorithms for multiprecision arithmetic are well-known (see TAOCP section 4.3 if you need a reference), there is often ha...
Unfortunately I am still not so strong in understanding [Sweep Line Algorithm](http://en.wikipedia.org/wiki/Sweep_line_algorithm). All papers and textbooks on the topic are already read, however understanding is still far away. Just in order to make it clearer I try to solve as many exercises as I can. But, really inte...
null
You're definitely on the right track. The big question is: when you insert a circle, which other circles do you check for intersection? How do you perform this check? In the line segment intersection case, the line segments at any given x coordinate are totally ordered. (You can list them from lowest to highest Y c...
So I'm really struggling with the pumping lemma. I think most of my problems come from not understanding how you can and can't split the string in a pumping lemma question. Here is an example, take the problem prove that L = {w | w contains more 0's than 1's over the language {0,1}} is not regular via the pumping lem...
Null Characters and Splitting the String in the Pumping Lemma
|proof-techniques|pumping-lemma|
You're definitely on the right track. The big question is: when you insert a circle, which other circles do you check for intersection? How do you perform this check? In the line segment intersection case, the line segments at any given x coordinate are totally ordered. (You can list them from lowest to highest Y c...
Yes, it is possible for $x$ or $y$ to be 'null', if by 'null' you mean the empty string. The empty string, $\epsilon$, is the string with length zero. If the loop in the automaton (which is ultimately what the pumping lemma refers to) starts at the initial state and the initial state is also an accepting state, the...
Unfortunately I am still not so strong in understanding [Sweep Line Algorithm](http://en.wikipedia.org/wiki/Sweep_line_algorithm). All papers and textbooks on the topic are already read, however understanding is still far away. Just in order to make it clearer I try to solve as many exercises as I can. But, really inte...
Yes, it is possible for $x$ or $z$ to be 'null', if by 'null' you mean the empty string. The empty string, $\epsilon$, is the string of length zero. If the loop in the automaton (which is ultimately what the pumping lemma refers to) starts at the initial state and the initial state is also an accepting state, then ...
CS.SE, I'm working on a ranking system that will rank entries based on votes that have been cast over a period of time. I'm looking for an algorithm that will calculate a score which is kinda like an average, however I would like it to favor newer scores over older ones. I was thinking of something along the lines...
looking for a ranking algorithm that favors newer entries
|algorithms|
I'm working on a ranking system that will rank entries based on votes that have been cast over a period of time. I'm looking for an algorithm that will calculate a score which is kinda like an average, however I would like it to favor newer scores over older ones. I was thinking of something along the lines of: ...
Looking for a ranking algorithm that favors newer entries
null
I have taught C++ to undergraduates for about two years and covered recursion. From my experience, your question and feelings are *very* common. At an extreme, some students see recursion as difficult to understand while others want to use it for pretty much everything. I think Dave sums it up well: use it where it ...
You could use any function that gives a lower weight to older entries. For example, if data consists of scores $s_i$, where $i$ corresponds to the 'time of arrival' of the entry, that is, newer entries have larger indices, then you could use a weight function that increase as $i$ increases. So any 'increasing' function...
So I'm really struggling with the pumping lemma. I think most of my problems come from not understanding how you can and can't split the string in a pumping lemma question. Here is an example, take the problem prove that $L = \{w | w$ contains more $0$'s than $1$'s over the language $\{0,1\} \}$ is not regular via th...
null
I'm working on a ranking system that will rank entries based on votes that have been cast over a period of time. I'm looking for an algorithm that will calculate a score which is kinda like an average, however I would like it to favor newer scores over older ones. I was thinking of something along the line of: ...
null
null
You could use any function that gives a lower weight to older entries. For example, if data consists of scores $s_i$, where $i$ corresponds to the 'time of arrival' of the entry, that is, newer entries have larger indices, then you could use a weight function that increase as $i$ increases. So any 'increasing' function...
|formal-languages|automata|proof-techniques|pumping-lemma|
The definition of continuity used by your teacher is the nicer one. It tells you pretty concretely what continuity means. Suppose $b \in f(x)$. That means that given all the information of $x$, possibly an infinite set of tokens (atoms), the function produces some element that has the atomic piece of information...
The definition of continuity used by your teacher is the nicer one. It tells you pretty concretely what continuity means. Suppose $b \in f(x)$. That means that given all the information of $x$, possibly an infinite set of tokens (atoms), the function produces some element that has the atomic piece of information...
The definition of continuity used by your teacher is the nicer one. It tells you pretty concretely what continuity means. Suppose $b \in f(x)$. That means that given all the information of $x$, possibly an infinite set of tokens (atoms), the function produces some element that has the atomic piece of information...
I really think "formal" methods are not a very good idea for educational purposes. For that matter, programming a computer is a "formal" method. Does it succeed as an educational tool? What is needed is understanding, intuition, and the ability to deal with abstraction. Formal methods hinder all that. Rather, th...
I'm really struggling with this property: > Let $X,Y$ be [coherence spaces](http://en.wikipedia.org/wiki/Coherent_space) and $f: Cl(X) \rightarrow Cl(Y)$ be a monotone function. $f$ is continuous if and only if $f(\bigcup_{x\in D} x)=\bigcup_{x \in D}f(x)$, for all $D \subseteq Cl(X)$ such that $D$ is a directed set...
null
$(\ast)$ If $L$ is a regular language, then $L^R$, the language consisting of the _reverse_ of all words in $L$, is also regular. Take this as an exercise. How does this help us solve the problem? Let $L_a,L_b,L_c$ be the languages consisting of all strings that evaluate to $a,b,c$ when evaluating from left to right...
Cute. First, build an automaton that computes the product from left to right. Easy! Put a transition $\overrightarrow x \xrightarrow{\;y\;} \overrightarrow z$ whenever $x \cdot y = z$. There are three states $\{\overrightarrow a,\overrightarrow b,\overrightarrow c\}$ representing the three possible products. Start i...
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...
|algorithms|data-mining|
I'm working on a ranking system that will rank entries based on votes that have been cast over a period of time. I'm looking for an algorithm that will calculate a score which is kinda like an average, however I would like it to favor newer scores over older ones. I was thinking of something along the line of: ...
|formal-languages|regular-languages|proof-techniques|pumping-lemma|
I have started to study non deterministic automata using the book of [Hopcroft][1]. I'm stuck in a problem that I found very interesting: > Give a non deterministic finite automaton accepting all the strings that > have the same value when evaluated left to right as right to left by > multiplying according to the ...
Words that have the same right- and left-associative product
|formal-languages|automata|regular-languages|finite-automata|nondeterminism|
Cute. First, build an automaton that computes the product from left to right. Easy! Put a transition $\overrightarrow x \xrightarrow{\;y\;} \overrightarrow z$ whenever $x \cdot y = z$. There are three states $\{\overrightarrow a,\overrightarrow b,\overrightarrow c\}$ representing the three possible products. Start i...
$(\ast)$ If $L$ is a regular language, then $L^R$, the language consisting of the _reverse_ of all words in $L$, is also regular. Take this as an exercise. How does this help us solve the problem? Let $L_a,L_b,L_c$ be the languages consisting of all strings that evaluate to $a,b,c$ when evaluating from left to right...
Assume that I am a programmer and I have an NPC problem that I need to solve it. What methods are available to deal with NPC problems? Is there a survey or something similar on this topic?
Dealing with intractability
|algorithms|np-hard|efficiency|