instruction
stringlengths
0
29.8k
⌀
Let $Y_v$ be the random variable that indicates whether vertex $v$ is added to the independence set. The probability that $v$ appears before all vertices that are incident to $v$ in a random ordering is $\frac1{\deg(v)+1}$, since all orderings are equally likely and all $\deg(v)+1$ vertices involved are symmetric to on...
null
null
Let $Y_v$ be the random variable that indicates whether vertex $v$ is added to the independence set. The probability that $v$ appears before all vertices that are incident to $v$ in a random ordering is $\frac1{\deg(v)+1}$, since all orderings are equally likely and all $\deg(v)+1$ vertices involved are symmetric to on...
I have a sequence of integer tuples $t_0, t_1,..., t_{N-1}$ of different sizes in lexicographic order, e.g.: $(1, 1), (1, 2), (1, 3, 5), (1, 3, 6), (1, 5), (3), (3, 2, 3), (3, 7), (3, 8, 1), ...$ - sequence length is $N \le 10^9 \space (2^{30})$, - a tuple size bounded by $S, |t| \le S \le 32$, - $i$-th ele...
Let $Y_v$ be the random variable that indicates whether vertex $v$ is added to the independence set. The probability that $v$ appears before all vertices that are incident to $v$ in a random ordering is $\frac1{\deg(v)+1}$, since all orderings are equally likely and all $\deg(v)+1$ vertices involved are symmetric to on...
Let $Y_v$ be the random variable that indicates whether vertex $v$ is added to the independence set. The probability that $v$ appears before all vertices that are incident to $v$ in a random ordering is $\frac1{\deg(v)+1}$, since all orderings are equally likely and all $\deg(v)+1$ vertices involved are symmetric to on...
I am doing an exercise related to maximizing Independent Set, I have $G = (V = \{v_1, . . . , v_n\}, E)$ as an undirected graph. This graph as $n!$ possible orderings for the vertices $V$. If we pick any such orderings uniformly at random i.e. let $\sigma = (\sigma_1, . . . , \sigma_n)$ be such random ordering then ...
Prove the expected size of the independence set got by a random algorithm is at least 1/d of the maximum size
|graphs|approximation|randomized-algorithms|independent-sets|
I believe you're looking for "[monotone minimal perfect hashing][1]". [1]: https://vigna.di.unimi.it/ftp/papers/TheoryPracticeMonotone.pdf
I am wondering if my solution is correct or I am on the right track. I have searched online and found a paper about [Java type system being unsound](https://dl.acm.org/doi/10.1145/2983990.2984004) but that doesn't really answer the progress and preservation issue. Question: Give a non-obvious problem in the langu...
I am wondering if my solution is correct or I am on the right track. I have searched online and found a paper about [Java type system being unsound](https://dl.acm.org/doi/10.1145/2983990.2984004) but that doesn't really answer the progress and preservation issue. Question: Give a non-obvious problem in the langu...
null
|programming-languages|lambda-calculus|
It might be clearer to ask yourself whether a set containing an empty set is the same as an empty set. Russell and Whitehead say, "No."
I am doing an exercise related to maximizing Independent Set, I have $G = (V = \{v_1, . . . , v_n\}, E)$ as an undirected graph. This graph as $n!$ possible orderings for the vertices $V$. If we pick any such orderings uniformly at random i.e. let $\sigma = (\sigma_1, . . . , \sigma_n)$ be such random ordering then ...
Think of the set containing the empty string as one, and the empty set as zero. A [Kleene algebra][1] is essentially an idempotent semi-ring, plus the Kleene closure operator. Ignoring the Kleene closure (a.k.a. Kleene star) operator, the ordered "multiplication" corresponds to string concatenation and "addition" co...
null
I am reading up on CYK. I understand that it requires the grammar to be in CNF. This however, is very restrictive, as it essentially removes the possibility of infinite number of parse trees in the parse forest. Are there any updates to CYK that allows epsilon rule to be used as production rule for arbitrary nontermina...
Are there any updates to CYK parsing that handles epsilon rules in arbitrary nonterminals?
|context-free|parsers|
null
I am wondering if my solution is correct or I am on the right track. I have searched online and found a paper about [Java type system being unsound](https://dl.acm.org/doi/10.1145/2983990.2984004) but that doesn't really answer the progress and preservation issue. Question: Give a non-obvious problem in the langu...
It can be divided basically into three steps: Step 1: For each character of the node, create a leaf node. The leaf node of a character contains the frequency of that character. Step 2: Set all the nodes in sorted order according to their frequency. Step 3: There may exist a condition in which two nodes may hav...
I have N nodes, a node might have an undirected edge to other nodes, resulting in K connected components (K<=N, K unknown). At each step in time, I can perform N/2 pair-wise tests *in parallel* to test if a pair of nodes is connected or not. Connectivity is transitive. The goal is to find all K components and list o...
Find connected components in a graph of computer network with parallel pairwise tests
|computer-networks|connected-components|
Why sometimes we would want to convert general trees or forests into a binary tree? And what's the main principle behind this convertion?
Why would we want to convert a forest or general tree to binary tree?
|data-structures|trees|binary-trees|
Why sometimes we would want to convert generic trees or forests into a binary tree? And what's the main principle behind this convertion?
Why would we want to convert a forest or generic tree to binary tree?
In the recursive triangulation you consider, you roughly divide the number of vertices by $2$ at each level of recursion. Thus, there are $O(\log n)$ levels of recursion. Consider some segment $S$. Among all the diagonals added at some level of recursion, $S$ can intersect at most $2$ (try to prove it!), so in total it...
null
Such a conversion can occur when trying to represent an abstract tree on a computer. If you consider an edge between a node and one of its children, it is natural to implement it as a memory pointer. However, on a generic tree, that would mean that each node could contain any number of memory pointers. This is not a...
Say you have a directed graph consisting of n nodes and containing edge weights. A starting node is also given. You want to begin your route at that node and visit each other node in the graph exactly once before returning to the starting node. Your goal is to take the route that has the smallest sum of edge weights po...
Transforming a Travelling Salesman Problem to a Maximum Clique Problem
|complexity-theory|graphs|weighted-graphs|traveling-salesman|clique|
I have N nodes, a node might have an undirected edge to other nodes, resulting in K connected components (K<=N, K unknown). I can test if a given pair is connected. In each step in time, I can run N/2 such tests *in parallel* (a given node can be tested once per step). Connectivity is transitive. The goal is to f...
TSP is reducible to SAT which is reducible to 3SAT which is reducible to CLIQUE. The reduction is not pretty, but still, it exists.
I am having some difficulties understanding how the `remove()` operation works step by step with the splay tree. My tree looks like so: 2 / \ 1 13 / 10 / 9 / 5 now I want to `remove(10)` and get the following tr...
Splay Tree remove step by step
|splay-trees|
I am having some difficulties understanding how the `remove()` operation works step by step with the splay tree. My tree looks like so: 2 / \ 1 13 / 10 / 9 / 5 now I want to `remove(10)` and get the following tr...
The deletion operation is exactly the same as in standard BST: - first, find the node $x$ to be deleted (either via a pointer or doing classic binary search); - if $x$ has no child, just delete it; - if $x$ has only one child $y$, then replace $x$ with the subtree rooted in $y$ and remove $x$; - otherwise you c...
The [splay tree paper](https://www.cs.cmu.edu/~sleator/papers/self-adjusting.pdf) presented two variations for delete: * The first will splay at the node $x$ to be removed then **join** its left and right trees. The join operation will splay $z$, the largest element of $x$'s left subtree, so it will be the root. The...
Imagine in real life an area full of mountains. Every village has a short connection to a central point X, but all other connections between villages are very, very long, due to the mountains. The shortest route is very easy to find: Go from A to X to B to X to C to X ... to Y to X to A. The order doesn't matter. Since...
The [splay tree paper](https://www.cs.cmu.edu/~sleator/papers/self-adjusting.pdf) presented two variations for delete: * The first will splay at the node $x$ to be removed then **join** its left and right trees. The join operation will splay $z$, the largest element of $x$'s left subtree, so it will be the root. The...
The [splay tree paper](https://www.cs.cmu.edu/~sleator/papers/self-adjusting.pdf) presented two variations for delete: * The first will splay at the node $x$ to be removed then **join** its left and right trees. The join operation will splay $z$, the largest element of $x$'s left subtree, so it will be the root. The...
Progress and preservation only really make sense in the context of term-rewriting, but there is no canonical definition of Java's semantics in that form. It seems possible to define Java's semantics in such a way that your answers are correct, but it should also be possible to define Java's semantics in such a way that...
How I solved the problem: $f(t_i) = i$, but it is possible to find element index quickly by using several static hash tables. ### Construction There are hash functions $h_1, h_2, h_3$ with codomains $1..M_1, 1..M_2, 1..M_3$ which are almost universal. 1. Allocate array $K_1$ of length $2M_1$ and fill it wit...
Binary trees have nodes of constant size, using two links: to the first descendant and to the sibling. This makes allocation easier.
null
I have a sequence of integer tuples $t_1, t_2,..., t_N$ of different sizes in lexicographic order, e.g.: $(1, 1), (1, 2), (1, 3, 5), (1, 3, 6), (1, 5), (3), (3, 2, 3), (3, 7), (3, 8, 1), ...$ - sequence length is $N \le 10^9 \space (2^{30})$, - a tuple size bounded by $S, |t| \le S \le 32$, - $i$-th element...
The best you can do is about $N$ steps. You can do it in about $N$ steps, by just testing $N/2$ new pairs in each step, until you've tested all pairs. Then once you have tested all pairs, you can use any standard algorithm to compute connected components (e.g., depth-first search). You can't do better. In the w...
I heard in my lecture that there are non regular languages which meet the requirements for the pumping lemma for regular languages but I never actually saw one. Does anybody have an example?
Which non regular language meets the requirements for pumping lemma for regular languages?
|regular-languages|context-free|pumping-lemma|chomsky-hierarchy|theory|
How I solved the problem: $f(t_i) = i$, but it is possible to find element index quickly by using several static hash tables. ### Construction There are hash functions $h_1, h_2, h_3$ with codomains $1..M_1, 1..M_2, 1..M_3$ which are almost universal. 1. Allocate array $K_1$ of length $2M_1$ and fill it wit...
null
Consider the geometric set cover problem https://en.wikipedia.org/wiki/Geometric_set_cover_problem. The Wiki article says there is a simple greedy algorithm for the one-dimension case, what is the analysis of that? Is there a constant approximation factor possible for the one-dimensional case if each of the sets ...
Geometric Set Cover in one dimension
|algorithm-analysis|combinatorics|approximation|set-cover|
It's an exercise question from chapter 0 of Michael Sipser's book Introduction to the Theory of Computation. >e. The set containing the empty string >f. The set containing nothing at all I guess the empty string is still something, which is not nothing. Would this be the difference?
What is the difference between the set containing the empty string and the set containing nothing at all?
null
Consider $x_1, …, x_n\in \mathbb{R}$ and $I_1, …, I_k$ be intervals, $I_i = [a_i, b_i]$. Suppose without loss of generality that $x_1 < x_2 < … < x_n$. Let $I_i$ be an interval such that $x_1 \in I_i$, and $b_i$ maximal for such intervals. Then there is an optimal solution containing $I_i$. Indeed, suppose $I_i$ ...
I see why ordinary Horn clauses (of the type Prolog might accept) are first order eg something like (with all variables universally quantified) $$ P(x) \leftarrow Q_1(x),Q_2(x,y).\\ P(x) \leftarrow Q_2(x,y),P(y).\\ $$ (I'm using the conventional notation of upper case for constants and lower case for variables, ra...
Constrained Horn Clauses vs. "ordinary" Horn Clauses
|logic|constraint-programming|logic-programming|
null
Progress and preservation are properties of a semantics, not of a language. It's possible to define a programming language in different ways which do not necessarily all have the same properties. Both are properties of semantics defined by an evaluation relation (either a partial evaluation as in small-step semantics o...
null
Pierce's _Types and Programming Languages_ has the following definition of terms: >$$S_0=\emptyset$$ >$$S_{i+1} = \{true,false,0\} \cup \{succ(t), pred(t),iszero(t)|t \in S_i\} \cup\{if(t_1)then (t_2)else(t_3) |t_1,t_2,t_3\in S_i\}$$ So then that means this language has terms like $succ(false)$ and $if(succ(0))t...
Types and programming languages: strange term construction?
|programming-languages|recursion|type-theory|language-design|typing|
You're interpreting this correctly. $S_1$ contains the constants, $S_2$ contains the terms you can build using if/else, the successor function, the predecessor function and the zero predicate with these constants. The language is the limit $S = \bigcup_i S_i$ which can be interpreted as allowing any number of applicati...
You're interpreting this correctly. $S_1$ contains the constants, $S_2$ contains the terms you can build using one application of if/else, the successor function, the predecessor function and the zero predicate with these constants. The language is the limit $S = \bigcup_i S_i$ which can be interpreted as allowing any ...
You're interpreting this correctly. $S_1$ contains the constants, $S_2$ contains the terms you can build using one application of if/else, the successor function, the predecessor function and the zero predicate with these constants. The language is the limit $S = \bigcup_i S_i$ which can be interpreted as allowing any ...
null
Consider the geometric set cover problem https://en.wikipedia.org/wiki/Geometric_set_cover_problem. The Wiki article says there is a simple greedy algorithm for the one-dimension case, what is the analysis of that? I have already asked this question before: https://cs.stackexchange.com/questions/156772/geometric-...
Greedy Algorithm for Geometric Set Cover
|algorithms|combinatorics|greedy-algorithms|set-cover|
I am reading up on CYK. I understand that it requires the grammar to be in CNF. This however, is restrictive, as it forces the grammar to be restructured to remove $\epsilon$ rules from arbitrary nonterminals (allowing it only on the start symbol). The problem with this is that, when transforming the CYK recognizer to ...
null
If you want to build a representation of all parse trees, I think a GLR (Tomita) parser is a better fit than something based on CYK. A GLR parser outputs a compact representation of the set of all parse trees, and does not require transformation to CNF.
The definitions of progress and preservation used in the question only really make sense in the context of term-rewriting, but there is no canonical definition of Java's semantics in that form. It may be possible to define Java's semantics in such a way that your answers are correct, but it is possible to define Java's...
Reading data is easy to understand: *cache missed, then read it from memory.* But writing data add more complexity: *write the data to both cache(s) and memory or only cache(s)?* ## Write after missed ![Write case 1][1] If the answer of ❸ and ❹ is *yes*, then you are using **Write-through**, else if the answ...
Reading data is easy to understand: *cache missed, then read it from memory.* But writing data add more complexity: *write the data to both cache(s) and memory or only cache(s)?* ## Write after missed ![Write case 1][1] If the answer of ❸ and ❹ is *yes*, then you are using **Write-through**, else if the answ...
I have N nodes, a node might have an undirected edge to other nodes, resulting in K connected components (K<=N, K unknown). I can test if a given pair is connected. In each step in time, I can run N/2 such tests *in parallel* (a given node can be tested once per step). Each connected component is a cluster graph (i...
This is a [follow-up question to my previous question](https://cs.stackexchange.com/questions/156721/example-of-progress-and-preservation-failing-in-a-commonly-used-programming-lang) I have been reading [this post](https://medium.com/hackernoon/java-is-unsound-28c84cb2b3f#.xs8voadvf) and it comes up with the followi...
Example of preservation failing in Java - follow up question
|programming-languages|lambda-calculus|
By applying the definition, $$S_0=\emptyset\\ S_1=\{\text{true},\text{false},0\}\\ S_2=\{\text{true},\text{false},0,\\ \text{succ}(\text{true}) , \text{pred}(\text{true}) , \text{iszero}(\text{true}) ,\\ \text{succ}(\text{false}) , \text{pred}(\text{false}) , \text{iszero}(\text{false}) ,\\ \text{succ}(0) ,...
By applying the definition, $$S_0=\emptyset\\ S_1=\{\text{true},\text{false},0\}\\ S_2=\{\text{true},\text{false},0,\\ \text{succ}(\text{true}) , \text{pred}(\text{true}) , \text{iszero}(\text{true}) ,\\ \text{succ}(\text{false}) , \text{pred}(\text{false}) , \text{iszero}(\text{false}) ,\\ \text{succ}(0) ,...
null
Prove the $NP$-hardness of $CONNECTEDNESS$ - the problem of counting over an oriented graph $G$ and two vertices $s$ and $t$ the number of subgraphs of $G$ in which from $s$ to $t$ can be traversed by an oriented path. Does the corresponding problem of recognition in $P$? If necessary, one can use the $NP$-hardness of...
Prove the NP-hardness of problem
|complexity-theory|np-hard|