instruction
stringlengths
0
29.8k
⌀
Here's a naive algorithm. It relies ultimately on brute force, but may perform okay sometimes. Each constraint $(\sigma_{m_i}, \sigma_{m_j}, \sigma_{m_k}) \in S \implies i < k \wedge \neg(i < j < k)$ consists of two conjuncts; let's call them type-$A$ and type-$B$. Consider each type-$B$ constraint as a disjunctio...
How to score a given arrangement of windows on a screen to produce good layouts
|complexity-theory|proof-techniques|
JeffE outlines the most common strategy: know lots of NP-complete problems, find one that fits very well and make the *easy* reduction. Another valid strategy is to *always* use 3SAT (or any other problem). This might make some reductions more intricate, but the upside is that you have *lots* of experience expressin...
Let $\mathrm{A}$ and $\mathrm{B}$ be two complexity classes. A separation ($\mathrm{A} \neq \mathrm{B}$) or collapse ($\mathrm{A} = \mathrm{B}$) is said to relativize if for all oracles $\mathrm{O}$ we have $\mathrm{A}^\mathrm{O} \neq \mathrm{B}^\mathrm{O}$ or $\mathrm{A}^\mathrm{O} = \mathrm{B}^\mathrm{O}$ respectivel...
You need to determine at what time each job is completed. With a first-come-first-served scheduler, this is simple to calculate: each job starts as soon as the processor becomes free, and takes exactly its burst time to complete. You've already calculated the start and end times to calculate the wait times, so use that...
null
I am writing a Program, solving the [Chinese Postman Problem](http://en.wikipedia.org/wiki/Route_inspection_problem) (also known as route inspection problem) in an undirected draph and currently facing the problem to find the best additional edges to connect the nodes with odd degree, so I can compute an Eulerian circu...
In Richard Gabriel's famous essay [The Rise of Worse is Better][1], he contrasts caricatured versions of the MIT/Stanford (Lisp) and New Jersey (C/Unix) design philosophies along the axes of simplicity, correctness, consistency, and completeness. He gives the example of the "PC loser-ing problem" ([discussed elsewhere...
What are examples of inconsistency and incompleteness in Unix/C?
|programming-languages|operating-systems|unix|design|
In Richard Gabriel's famous essay [The Rise of Worse is Better][1], he contrasts caricatured versions of the MIT/Stanford (Lisp) and New Jersey (C/Unix) design philosophies along the axes of simplicity, correctness, consistency, and completeness. He gives the example of the "PC loser-ing problem" ([discussed elsewhere...
|algorithms|optimization|scheduling|
|complexity-theory|proof-techniques|relativization|
null
I'm studying Bootstrapping from Red Dragon Book Compilers and found the T diagram for cross compiler pretty confusing. I can't understand what is meant by "Run compiler1 through compiler2". Can anyone provide some better explanation, analogy or an example to relate with some real world compiler. > Compiling a Co...
Cross Compiler's T diagram
|untagged|
It means that we compile LSN with SMM, that is, run source code of LSN through SMM. When SMM compiles some source code, it produces an executable for machine M, so when we compile LSN with SMM we get LMN - an executable, which compiles L source files on machine M in order to produce executables for machine N. Per...
|compilers|
*Consistency* Lisp has a very consistent syntax, all language extensions can be embedded naturally via macros and such. C, on the other hand, has a rather code syntax, which allows one to take some "shortcuts", so in some cases C code actually look simplier. *Completeness* In Lisp, if you do not have a specifi...
Here's a naive algorithm. It relies ultimately on brute force, but may perform okay sometimes. Each constraint $(\sigma_{m_i}, \sigma_{m_j}, \sigma_{m_k}) \in S \implies i < k \wedge \neg(i < j < k)$ consists of two conjuncts; let's call them type-$A$ and type-$B$. Consider each type-$B$ constraint as a disjunctio...
Here's a naive algorithm. It relies ultimately on brute force, but may perform okay sometimes. Each constraint $(\sigma_{m_i}, \sigma_{m_j}, \sigma_{m_k}) \in S \implies i < k \wedge \neg(i < j < k)$ consists of two conjuncts; let's call them type-$A$, $i < k$, and type-$B$, $\neg(i < j < k)$. Each type-$B$ constr...
I'm studying Bootstrapping from Red Dragon Book Compilers and found the T diagram for cross compiler pretty confusing. I can't understand what is meant by "Run compiler1 through compiler2". Can anyone provide some better explanation, analogy or an example to relate with some real world compiler? Some notation first ...
I'm studying Bootstrapping from Red Dragon Book Compilers and found the T diagram for cross compiler pretty confusing. I can't understand what is meant by "Run compiler1 through compiler2". Can anyone provide some better explanation, analogy or an example to relate with some real world compiler? Some notation first ...
I'm studying Bootstrapping from Red Dragon Book Compilers and found the T diagram for cross compiler pretty confusing. I can't understand what is meant by "Run compiler1 through compiler2". Can anyone provide some better explanation, analogy or an example to relate with some real world compiler? Some notation first ...
null
JeffE outlines the most common strategy: know lots of NP-complete problems, find one that fits very well and make the *easy* reduction. Another valid strategy is to *always* use 3SAT (or any other problem). This might make some reductions more intricate, but the upside is that you have *lots* of experience expressin...
The T-diagrams (which you had omitted from the original version of your question) are crucial for understanding these. Let's look at the last T-diagram. ![enter image description here][1] The first T describes a compiler from L to N written in S. The second T describes a compiler from S to M written in M (or r...
I'm studying Bootstrapping from Red Dragon Book Compilers and found the T diagram for cross compiler pretty confusing. I can't understand what is meant by "Run compiler1 through compiler2". Can anyone provide some better explanation, analogy or an example to relate with some real world compiler? Some notation first....
The T-diagrams (which you had omitted from the original version of your question) are crucial for understanding this sort of question. Let's look at the last T-diagram. ![enter image description here][1] The first T describes a compiler from L to N written in S. The second T describes a compiler from S to M wr...
We are given a set F={a1,a2,a3,…,aN} of N Fruits. Each Fruits has price Pi and vitamin content Vi.Now we have to arrange these fruits in such a way that the list contains prices in ascending order and the list contains vitamins in descending order. For example:: N=4 Pi: 2 5 7 10 Vi: 8 11 9 2 Hence if we arr...
Print Maximum List
|algorithms|
null
We are given a set F={a1,a2,a3,…,aN} of N Fruits. Each Fruits has price Pi and vitamin content Vi.Now we have to arrange these fruits in such a way that the list contains prices in ascending order and the list contains vitamins in descending order. For example:: N=4 Pi: 2 5 7 10 Vi: 8 11 9 2 Hence if we arr...
I am having a problem trying to solve a question on a past paper asking to design a security lattice. Here is the question: The AB model (Almost Biba) is a model for expressing integrity policies rather than confidentiality. It has the same setup as Bell-LaPadula, except that L is now a set of int...
Security Lattice Construction
|security|
A dynamic programming solution would work here, if the vitamin contents come from a finite set (for instance, bounded integers). First, sort the fruits on price ascending and in the cases were two or more fruit have the same price, sort them on vitamin content (descending). Now, define M[f, v] to be the maximal numb...
We are given a set $F=\{f_1, f_2, f_3, …, f_N\}$ of $N$ Fruits. Each Fruit has price $P_i$ and vitamin content $V_i$; we associated fruit $f_i$ with the ordered pair $(P_i, V_i)$. Now we have to arrange these fruits in such a way that the sorted list contains prices in ascending order and vitamin contents in descending...
Find subsequence of maximal length simultaneously satisfying two ordering constraints
We are given a set $F=\{f_1, f_2, f_3, …, f_N\}$ of $N$ Fruits. Each Fruit has price $P_i$ and vitamin content $V_i$; we associated fruit $f_i$ with the ordered pair $(P_i, V_i)$. Now we have to arrange these fruits in such a way that the sorted list contains prices in ascending order and vitamin contents in descending...
I am having a problem trying to solve a question on a past paper asking to design a security lattice. Here is the question: > The AB model (Almost Biba) is a model for expressing integrity policies rather than confidentiality. It has the same setup as Bell-LaPadula, except that L is now a set of integ...
null
Suppose i had an array of intergers having Length N. How to print all posssible LDS?? I know how to print the length of LDS,but don't know how to print all possible LDS? PseudoCode Will be more helpful
How to print all possible LDS
|algorithms|
Suppose I have an array of integers having length N. How can I output all longest decreasing sequences? I know how to calculate the length of longest decreasing sequences, but don't know how to report all longest decreasing sequences. Pseudocode will be helpful.
How to output all longest decreasing sequences
null
null
For every decreasing sequence, store the initial value of the id in another array. for(i=0;i< n-1; i++) { if(a[i] > a[i+1]) { temp[j++]=i; while(a[i] > a[i+1]) i++; temp[j++]=i; } } Now the array temp will contain initial and final positions of all the decreasing sequences consecutively. ...
For every decreasing sequence, store the initial positions in another array. for(i=0;i< n-1; i++) { if(a[i] > a[i+1]) { temp[j++]=i; while(a[i] > a[i+1]) i++; temp[j++]=i; } } Now the array temp will contain initial and final positions of all the decreasing sequences consecutively. Then p...
What operations need to be performed in order to do any arbitrary analogue computation? Would addition, subtraction, multiplication and division be sufficient? Also, does anyone know exactly what problems are tractable using analogue computation, but not with digital?
What is required for universal analogue computation?
|complexity-theory|
For every decreasing sequence, store the initial positions in another array. for( i = 0; i < n-1; i++ ) { if ( a[i] > a[i+1] ) { temp[j++] = i; while( a[i] > a[i+1] ) { i++; } temp[j++] = i; } } Now the array temp will...
null
The needed data structure is an _occur list_, a list for each variable containing the clauses the variable occurs in. These lists are built once, when the CNF is first read. They are used in steps 3 and 5 below to avoid scanning the whole CNF formula to count satisfied clauses. A better algorithm than flipping ev...
null
|complexity-theory|computation-models|turing-completeness|
|quantum-computing|circuits|turing-completeness|
|computability|programming-languages|turing-machines|turing-completeness|
|programming-languages|operating-systems|
This paper by [Delvenne][1] proposes a unifying formalism for universality in discrete (e.g. Turing Machines) and continuous (e.g. differential equations) dynamical systems and reviews some universal systems studied in the literature. Here is an excerpt from the paper which informally describes the procedure for provin...
null
Unfortunately, there is no "universal" concept of universality in analogue computing. However, this paper by [Delvenne][1] proposes a unifying formalism for universality in discrete (e.g. Turing Machines) and continuous (e.g. differential equations) dynamical systems and reviews some universal systems studied in the li...
IIRC my teacher said the inability to using `char *` variables in `switch` statements in C is a matter of inconsistency, but for me that was generality (completeness) issue. I think it's better to use "consistency" just in *your* algorithms or software design not in programming language itself, because programming lang...
IIRC my teacher said the inability to using `char *` variables in `switch` statements in C is a matter of inconsistency, but for me that was generality (completeness) issue. I think it's better to use "consistency" just in *your* algorithms or software design not in programming language itself (at least not in language...
I am having a problem trying to solve a question on a past paper asking to design a security lattice. Here is the question: > The AB model (Almost Biba) is a model for expressing integrity policies rather than confidentiality. It has the same setup as Bell-LaPadula, except that $L$ is now a set of int...
|security|lattices|integrity|
|computability|computation-models|turing-completeness|
What operations need to be performed in order to do any arbitrary [analogue computation][1]? Would addition, subtraction, multiplication and division be sufficient? Also, does anyone know exactly what problems are tractable using analogue computation, but not with digital? [1]: http://en.wikipedia.org/wiki/An...
I don't think the question can be answered unless we have a definition of what kind of computations we are talking about. If your question is if there are physical systems that starting from an initial state will reach another state in some time and if that is always computable, then the answer depends on what kind ...
I don't think the question can be answered unless we have a definition of what kind of computations we are talking about. Universality of a machine model w.r.t. a class of computationw means that any computation in that class can be computed by a machine. Unless you define the class of "arbitrary analogue computatio...
null
A dynamic programming solution would work here, if the vitamin contents come from a finite set (for instance, bounded integers). First, sort the fruits on price ascending and in the cases were two or more fruit have the same price, sort them on vitamin content (descending). Now, define $M[f, v]$ to be the maximal nu...
Suppose I have an array of integers having length $N$. How can I output all longest decreasing sequences? (A subsequence consists of elements of the array that do not have to be consecustive, for example $(3,2,1)$ is a decreasing subsequence of $(7,3,5,2,0,1)$.) I know how to calculate the length of longest decreasing ...
|algorithms|arrays|
<BR> this is the recurse formula:<br> **T(n)=9T(n/27)+(n*lgn)^1/2**<br> I started with a=9,b=27 and f(n)=(n*lgn)^1/2 for using the master method by "n^logb(a)" And if so n^log27(9)==n^(2/3) but i dont understand how to play with the (n*lgn)^1/2 . I think that the (n*lgn)^1/2 is bigger than n^(2/3) but I'm sure I s...
How to solve recursive algorithms using master method
|algorithm-analysis|asymptotics|
this is the recursive formula: $$T(n)=9T(n/27)+(n \cdot \lg(n))^{1/2}$$ I started with $a=9,b=27$ and $f(n)=(n\cdot \lg n)^{1/2}$ for using the [master theorem][1] by $n^{\log_b(a)}$, and if so $n^{\log_{27}(9)}=n^{2/3}$ but I don't understand how to play with the $(n\cdot \lg n)^{1/2}$. I think that the $(n\c...
How to solve recursive algorithms using master theorem
|algorithm-analysis|asymptotics|recursion|
$f(n) = (n\cdot \lg n)^{1/2}$ and $n^{\log_b a}=n^{2/3}$, thus $f(n) = O(n^{\log_b a})$ and even $f(n) = O(n^{\log_b a - \epsilon})$ for $\epsilon < 1/6$. Why? because $$\lim_{n\to\infty} \frac{f(n)}{n^{\log_b a - \epsilon}} = \lim_{n\to\infty}\frac{n^{1/2}\lg^{1/2}n}{n^{2/3-\epsilon}} = \lim_{n\to\infty} \frac{\...
|algorithm-analysis|asymptotics|recursion|
null
I was reviewing some NP-complete problems on this site, and I meet one interesting problem from http://cs.stackexchange.com/questions/808/np-completeness-proof-of-a-spanning-tree-problem In this problem, I am interested in the original problem, which the leaf set is precisely $S$. The author said that he can pro...
np completeness problem on spanning tree
|complexity-theory|np-complete|spanning-trees|
null
Looking for a list of informed search algorithms. I'm aware of: 1.best-first search - Greedy best-first - A * Are there more best-first algorithm or other informed searches that are not best-first?
Where can I find a list of informed search algorithms?
|algorithms|artificial-intelligence|search-algorithms|
Let M be a 0, 1 matrix. We say two entry are neighbors if they are adjacent horizontal or vertically, and both entry are 1's. One want to find minimum number of 1's to add, so every 1 can reach another one through a sequence of neighbors. Example: 100 000 001 need 3 1's 100 100 ...
Find minimum number 1's so the matrix consist of 1 connected region of 1's
|algorithms|