instruction
stringlengths
0
29.8k
⌀
I've used RPN several times for rapid prototyping, e.g. of programs that have to read and interpret a user-supplied mathematical expression. Whereas regular mathematical notation would require at least a recursive parser (think brackets, operator order, etc...), an RPN parser is basically a stack with a `switch`-lik...
null
I've used RPN several times for rapid prototyping, e.g. of programs that have to read and interpret a user-supplied mathematical expression. Whereas regular mathematical notation would require at least a recursive parser (think brackets, operator order, etc...), an RPN parser is basically a stack with a `switch`-lik...
With regards to calculators: See [What is RPN?][1] - Benefits: RPN saves time and keystrokes. You avoid using and keeping track of parentheses while doing calculations. The process is similar to the way you learned math on paper. - You can see the intermediary results as you perform your computations rather th...
|programming-languages|semantics|
null
null
In helping someone understand phrase generators for use with testing grammars, think compiler test cases, I noted that I have never found a phrase generator that is knowledgeable of the grammar, and is deterministic. The phrase generators I am talking about rely on the grammar of the language as input so that the user ...
|reference-request|formal-grammars|context-free|parsing|software-testing|
how about a simple near-visceral illustrative example using one of the most ubiquitous algorithms/applications in CS, namely sorting? [Bubblesort](http://en.wikipedia.org/wiki/Bubblesort) takes $O(n^2)$ both average and worst case time and [quicksort](http://en.wikipedia.org/wiki/Quicksort) about $O(n \log n)$ on avera...
how about a simple near-visceral illustrative example using one of the most ubiquitous algorithms/applications in CS, namely sorting? [Bubblesort](http://en.wikipedia.org/wiki/Bubblesort) takes $O(n^2)$ both average and worst case time and [quicksort](http://en.wikipedia.org/wiki/Quicksort) about $O(n \log n)$ on avera...
The interesting question is: what is the alternative? The only other method I know is testing/benchmarking. We program the algorithms, let them run on (a representative sample of) the finite input set and compare the results. There are a couple of problems with that. * The results are not general in terms of machin...
Let $S$ and $F$ be the set of all states and all accepting states of $\mathcal{A}$, respectively. For $t \in S \setminus F$, let $\mathcal{A}$ be the automaton obtained by making $t$ the only accepting state. For $t \in S \setminus F$, let $\mathcal{B}_t$ be the automaton obtained by removing all states in $F$, and mak...
null
The tools you refer to are probably already deterministic. Tools that accept a seed *probably* only employ a pseudorandom generator which is keyed from the seed and nothing else. Therefore, given the seed, everything is completely deterministic. If the seeding process is reasonable, then a seed like $0$ or $1$ should w...
I'm not an expert, but judging from the Wikipedia articles, YCbCr is used for image compression (JPEG and television [YPbPr]), while HSI is used in computer vision. Since you're doing computer vision, if we believe Wikipedia then you should use HSI. Of course, you could always experiment with both representations and a...
null
I recently read an article [Scott Aaronson - Big Numbers](http://www.scottaaronson.com/writings/bignumbers.html) . That has made me think about the effective upper-bound for sorting. According to the article, some of the big numbers like the number of particles in the universe and age of universe in milliseconds are...
Upper-bounding the number of comparisons for Sorting to $\Theta(n)$ using a physically big number like Number of Particles in the Universe
|algorithm-analysis|sorting|
The reasoning is not wrong as such, but applying such constraints tends to make asymptotic analysis meaningless; for example we could simply choose $C' = 10^{100}$, and as all inputs are smaller than this, every algorithm is $O(1)$. Despite the ability to limit the analysis physically and end up with trivial observa...
|machine-learning|computer-games|
Just to expand the previous answers/comments: don't forget that RPN is *alive and on great form* ... indeed it is currently used in **[stack machines][1]** like the Java virtual machine. From Wikipedia: *"... a stack machine implements a stack with registers. The operands of the arithmetic logic unit (ALU) are alway...
Is it possible to reduce MaxUNSAT to [MaxSAT][2] in a polynomial way ? When considering the MaxSAT problem, one often considers also the `MinUNSAT` problem, which is almost the same. And for a propositional formula `f` in [CNF][1] it holds: |f| = MaxSAT(f) + MinUNSAT(f) where `|f|` is the number of clauses...
How to reduce MaxUNSAT to MaxSAT (directly)?
null
|algorithms|graphs|graph-traversal|
|algorithms|graphs|graph-traversal|eulerian-paths|
|algorithms|graphs|search-algorithms|graph-traversal|
Forth and PostScript (and thus PDF which IIRC started as a binary encoding of a subset of PostScript) are more well known postfix languages that HP pocket calculator one. Then it is also a relatively common choice as intermediate representation in simple compilers. The simpler VM tend to have also a postfix "mach...
In helping someone understand phrase generators for use with testing grammars, think compiler test cases, I noted that I have never found a phrase generator that is knowledgeable of the grammar, and is deterministic. The phrase generators I am talking about rely on the grammar of the language as input so that the user ...
Yes. If you start with a Euler cycle for the graph and restrict to a biconnected component, then what you have is still a cycle on the biconnected component (basically, if the euler cycle leaves vertex v in the biconnected component, then you know it must return to the biconnected component through v, otherwise we cou...
If a graph has a Euler cycle, do the biconnected components have Euler cycles as well?
Euler cycles in biconnected components
|graphs|eulerian-paths|
I think you are correct: All neighbors of a node will be of rank one less (the node we got here from) or one more (or two more, etc) because we will rank them before we back out of the node.
In an undirected graph, can two nodes at an identical distance n from the root of a [DFS][1] tree be neighbors in the original graph? I'm thinking no, but I'm not sure (because of back edges) [1]: http://en.wikipedia.org/wiki/Depth-first_search
Can two neighbors in a graph be at the same depth in a DFS tree?
|graphs|graph-traversal|
The wikipedia article states that "it can be shown that if the graph is undirected then all of its edges are tree edges or back edges." If you find out how this can be shown, you should be quite close to your solution.
Your question does not stipulate how the DFS tree is generated. Naive implementations simply list nodes in the order they are visited, but most practical implementations rebuild the output tree as the search progresses and the ranks of the nodes are adjusted. Consider three nodes, A B C, connected to each other. A...
Look at the Max Flow Min Cut algorithm.
Use BFS to work backwards from v, flagging each vertex as 'visited' as you go. If you ever hit a vertex you've previously visited, your graph doesn't have the uniqueness property. Otherwise, it does.
I'm designing an algorithm for class that will determine if a graph is unique with respect to a vertex v such that for any u <> v there is at most one path from v to u. I've started by using BFS to find the shortest path from v to another vertex u, and then running BFS again to see if an alternate path can be found fro...
unique path in a directed graph
|graphs|graph-traversal|
It's a simple modification of any graph traversal: if you find an edge to a previously marked node, then you have multiple paths.
null
I want to understand what the `LEADING` and `TRAILING` of non-terminal in an operator precedence grammar physically mean. I am confused by the various definitions I have read on them. <br> I understand that the `LEADING` of a non-terminal is the first terminal which can be present in it's derivation. <br> On the o...
Understanding LEADING and TRAILING operations of an operator precedence grammar
|parsing|
Let's say $F$ is an oracle for a problem in $\mathbb{NP}$, but I cannot call this oracle with any input instance. Instead, whenever I call $F$ I get returned a random instance and solution. Thus, I know that $F$ is in fact capable of solving arbitrary $\mathbb{NP}$-hard problems, I just can't specify which one I wan...
Is an oracle ever useful if you can't control the input instances?
|complexity-theory|np-complete|
> Fifth, every text I've read mentions the class RNC but gives no examples of problems it contains. Are there any? The paper "Matching is as Easy as Matrix Inversion" by Mulmuley, Vazirani, and Vazirani has several examples of problems in class $\mathbb{RNC}^2$. The main one is finding a maximal matching, then they...
I see **structural induction** the usual way for proving an algorithm's **termination** property, but it's not that easy to prove by means of induction on a **tree** algorithm. Now I am struggling on proving that the pre-order tree traversal algorithm is terminable: preorder(node) if node == null then ret...
how to prove that the pre-order tree traversal algorithm is terminable?
|algorithms|
Given a relation R(A, B, C, D, E, F), with the following functional dependencies: {A -> BC, CD -> E, B->D, E->A}. The objective is to decompose R into 3NF relations. So far, I have determined that the following candidate keys are present in the given relation: AF, EF, CDF and BCF. Since every attribute is pr...
Decomposition of a relation to 3NF
|database-theory|
I see **structural induction** the usual way for proving an algorithm's **termination** property, but it's not that easy to prove by means of induction on a **tree** algorithm. Now I am struggling on proving that the pre-order tree traversal algorithm is terminable: preorder(node) if node == null then ret...
How to prove that the pre-order tree traversal algorithm is terminable?
null
I see **structural induction** the usual way for proving an algorithm's **termination** property, but it's not that easy to prove by means of induction on a **tree** algorithm. Now I am struggling on proving that the pre-order tree traversal algorithm is terminable: preorder(node) if node == null then ret...
I'm designing an algorithm for class that will determine if a graph is unique with respect to a vertex $v$ such that for any $u \ne v$ there is at most one path from $v$ to $u$. I've started by using BFS (breadth-first search) to find the shortest path from v to another vertex u, and then running BFS again to see if an...
|graphs|shortest-path|graph-traversal|
null
|terminology|formal-grammars|parsing|
|algorithms|algorithm-analysis|correctness-proof|
My homework is implementing algorithms BFS, DFS, depth-limited and IDS for the map as a 2D grid with 8 directions of movement. I read that the IDS algorithm is optimal, but in my case is not optimal paths. Is the IDS algorithm optimal for graphs (e.g. map as a grid), or does optimality only apply to searching tree...
IDS algorithm optimality for grid?
|graphs|graph-traversal|
As I am detouched from the subject for a long gap I have taken help from Wikipedia. A relational schema is in 3NF if for all of its FD X->A atleast one of the following holds 1) X contains A 2) X is a superkey 3) A-X is a prime attribute For your problem any of the FD's are not being satisfied on point 1. For ...
Even if there's a simulation in each direction, the simulations back and forth may not relate the same sets of states. Sometimes you have a simulation $R_1$ in one direction, and a simulation $R_2$ in the other direction, and two states $p_1$ and $q$ which are related by $R_1$ but not by $R_2$ nor by any other simulati...
The notion of best-case running time is kind of ambiguous for me. According to wikipedia, the definition of best case running time is: >The term best-case performance is used in computer science to describe the way of an algorithm behaves under optimal conditions. For example, the best case for a simple linear searc...
Best Case Running Time For Binary Search Tree Insertion
|runtime-analysis|binary-trees|
Is it possible to reduce MaxUNSAT to [MaxSAT][2] in a polynomial way ? When considering the MaxSAT problem, one often considers also the `MinUNSAT` problem, which is almost the same. And for a propositional formula `f` in [CNF][1] it holds: |f| = MaxSAT(f) + MinUNSAT(f) where `|f|` is the number of clauses...
How to reduce MaxUNSAT to MaxSAT?
In question [How to reduce MaxUNSAT to MaxSAT?][1] I was asking, how to reduce the MaxUNSAT problem to MaxSAT. With help of the given answer I could give a polynomial reduction : $MaxUNSAT \leq decisionProblemMaxUNSAT \leq SAT \leq MaxSAT$. **Question:** Is there a more direct reduction without much overhead from Ma...
How to reduce MaxUNSAT to MaxSAT in a (almost) direct way?
|optimization|reductions|satisfiability|
The notion of best-case running time is kind of ambiguous for me. According to wikipedia, the definition of best case running time is: >The term best-case performance is used in computer science to describe the way of an algorithm behaves under optimal conditions. For example, the best case for a simple linear searc...
Best-Case Running Time For Binary Search Tree Insertion
|terminology|data-structures|runtime-analysis|binary-trees|
Both! That is, if you are lenient with what "best-case" means. The best-case is the input for respectively run¹ of an algorithm which minimises runtime (for a given size). I guess that some of your sources refer to (asymptotically) optimal BST implementations, either them or you mixing up the notions. These are the...
|complexity-theory|optimization|reductions|satisfiability|