instruction
stringlengths
0
29.8k
⌀
Using an answer to write down a nice insight, inspired by the comments: **Definition**. A function $f: \Sigma^s \to \{0, ..., s-1\}$ is called *shift-invariant* if $\forall w \in \Sigma^s, c \in \Sigma: f(w_0...w_{s-1}) > 0 \Rightarrow f(w_1...w_{s-1}c) = f(w_0...w_{s-1}) - 1$. **Definition**. For a finite set of...
Using an answer to write down a nice insight, inspired by the comments: **Definition**. A function $f: \Sigma^s \to \{0, ..., s-1\}$ is called *shift-invariant* if $\forall w \in \Sigma^s, c \in \Sigma: f(w_0...w_{s-1}) > 0 \Rightarrow f(w_1...w_{s-1}c) = f(w_0...w_{s-1}) - 1$. **Definition**. For a finite set of...
I'm having a lot of troubles understanding a preparation exercise about oriented graphs: > Consider the following game played on a directed graph G = (V, E) with > n nodes and m edges. A pawn is initially placed on node s. The pawn > can be moved from its current position u to a node v if there exists a > directe...
Checking if all nodes are reachable in a oriented graph from all other nodes
|graphs|graph-traversal|
Using an answer to write down a nice insight, inspired by the comments: **Definition**. A function $f: \Sigma^s \to \{0, ..., s-1\}$ is called *shift-invariant* if $\forall w \in \Sigma^s, c \in \Sigma: f(w_0...w_{s-1}) > 0 \Rightarrow f(w_1...w_{s-1}c) = f(w_0...w_{s-1}) - 1$. **Definition**. For a finite set of...
Using an answer to write down a nice insight, inspired by the comments: **Definition**. A function $f: \Sigma^s \to \{0, ..., s-1\}$ is called *shift-invariant* if $\forall w \in \Sigma^s, c \in \Sigma: f(w_0...w_{s-1}) > 0 \Rightarrow f(w_1...w_{s-1}c) = f(w_0...w_{s-1}) - 1$. **Definition**. For a finite set of...
We want to use a $\textsf{MAX-CUT}$ algorithm to solve the $\textsf{MAX-3-CUT}$ problem. Therefore we need to transform our original graph $G$ into a new graph $G'$ in such a way that finding a max-cut on $G'$ tells us how to cut $G$ into 3. Let's start by creating, for every $v \in V(G)$ three vertices $v_A, v_B, v...
Using an answer to write down a nice insight, inspired by the comments: **Definition**. A function $f: \Sigma^s \to \{0, ..., s-1\}$ is called *shift-invariant* if $\forall w \in \Sigma^s, c \in \Sigma: f(w_0...w_{s-1}) > 0 \Rightarrow f(w_1...w_{s-1}c) = f(w_0...w_{s-1}) - 1$. **Definition**. For a finite set of...
Using an answer to write down a nice insight, inspired by the comments: **Definition**. A function $f: \Sigma^s \to \{0, ..., s-1\}$ is called *shift-invariant* if $\forall w \in \Sigma^s, c \in \Sigma: f(w_0...w_{s-1}) > 0 \Rightarrow f(w_1...w_{s-1}c) = f(w_0...w_{s-1}) - 1$. **Definition**. For a finite set of...
I am looking for a variant of the knapsack problem in which the items are nodes in an undirected graph, and the knapsack must be filled with a connected subgraph. Formally: * The input is an undirected graph $G=(V,E)$, where each node $v\in V$ has both a size and a value; and a knapsack capacity $C$. * The goal is ...
knapsack with graph connectivity constraints
|dynamic-programming|knapsack-problems|pseudo-polynomial|
There shouldn't be a pseudopolynomial-time algorithm; the problem is NP-hard even if all values are given in unary. We can reduce from Connected Vertex Cover problem in which we need to decide whether a graph has a connected subgraph of at most $k$ vertices touching all edges. This is NP-hard by a simple reduction from...
One way to deal with having these special vertices is to create a [reversed graph](https://en.m.wikipedia.org/wiki/Transpose_graph) from your original graph, which can be done in $O(n+m)$ time, assuming you are using adjacency list representation. This reversed graph contains all vertices but with the direction of the ...
null
|algorithms|time-complexity|dynamic-programming|
There are $n$ people and $m$ jobs. We would like to assign at most one job to each person. For each person,job pair, there is a positive value determining the fitness of this person to that job. The goal is to find an assignment that maximizes the total value. So far, it is exactly the problem of finding a maximum-we...
High-multiplicity maximum-weight matching
|algorithms|matching|assignment-problem|
null
Suppose we have sets $X$ and $Y$, $|X|=m$, $|Y|=n$. $H$ is a universal family of hash functions from $X$ to $Y$. Let $S\subsetneq X$ be a proper subset of $X$. Does there exist some "partial" universal hash family that is universal on $S$ to $Y$, but not necessarily universal on $X$ to $Y$? The circuit complexity of th...
Does there exist some ``partial" universal hashing?
|complexity-theory|circuits|cryptography|hashing|
You can solve this using [min-cost flow](https://en.wikipedia.org/wiki/Minimum-cost_flow_problem). Construct a graph with a source vertex $s$, one vertex per person, one vertex per job, and one sink $t$. Add edges as follows: - Add an edge of capacity 1 from $s$ to each person, with cost 0. - Add an edge of c...
Sure, of course. Let $S$ be a single point, so $|S|=1$; then any family is trivially a universal hash on $S \to Y$, and is faster than $H$, even though it is not universal on $X \to Y$.
null
Suppose we have sets $X$ and $Y$, $|X|=m$, $|Y|=n$. $H$ is a universal family of hash functions from $X$ to $Y$. Let $S\subsetneq X$ be a proper subset of $X$. Does there exist some "partial" universal hash family that is universal on $S$ to $Y$, but not necessarily universal on $X$ to $Y$? The circuit complexity of th...
Suppose we have sets $X$ and $Y$, $|X|=m$, $|Y|=n$. $H$ is a universal family of hash functions from $X$ to $Y$. Let $S\subsetneq X$ be a proper subset of $X$. Does there exist some "partial" universal hash family that is universal on $S$ to $Y$, but not necessarily universal on $X$ to $Y$? The circuit complexity of th...
null
All of the discussion is in the context of [this][1] paper. I think that the whole procedure that the paper describes is not decidable, because if we can have an algorithm for it, then we can solve halting problem. I begin with the definition of termination, which has not been expressed in the paper. First thing...
Does this paper by Patrick Cousot describe an undecidable method for model checking?
|undecidability|halting-problem|formal-methods|model-checking|denotational-semantics|
<M,<M>> is like the functionality of the following C++ codes: (file name: test_self.cpp) #include <iostream> #include <fstream> #include <string> using namespace std; int main() { fstream out("test_self.cpp", ios::in); if(!out){ cout << "Can't open t...
<M,<M>> is like the functionality of the following C++ codes: (file name: test_self.cpp) #include <iostream> #include <fstream> #include <string> using namespace std; int main() { fstream out("test_self.cpp", ios::in); if(!out){ cout << "Can't open...
<M,<M>> is like the functionality of the following C++ codes: (file name: test_self.cpp) #include <iostream> #include <fstream> #include <string> using namespace std; int main() { string file_name; cout << "Enter the file name: "; cin >> file_name; ...
<M,\<M>> is like the functionality of the following C++ codes: (file name: test_self.cpp) #include <iostream> #include <fstream> #include <string> using namespace std; int main() { string file_name; cout << "Enter the file name: "; cin >> file_name; ...
null
<M,\<M>> is like the functionality of the following C++ codes: (file name: test_self.cpp) #include <iostream> #include <fstream> #include <string> using namespace std; int main() { string file_name; cout << "Enter the file name: "; cin >> file_name; ...
null
Given: A planar undirected connected graph G in which degree of every vertex is 2 or more. Fact: A planar graph can have multiple planar embeddings. Question: Give an efficient algorithm to find the set S of face cycles corresponding to any one of the planar embeddings. We do not care about from which specific e...
Enumerate faces in any one embedding of a planar graph
|graphs|planar-graphs|
Given: A planar undirected connected graph $G$ in which degree of every vertex is $2$ or more. Fact: A planar graph can have multiple planar embeddings. Question: Give an efficient algorithm to find the set $S$ of face cycles corresponding to any one of the planar embeddings. We do not care about from which spec...
null
This is might not be exactly what you are looking for, but you can build a data structure with $O(n^2\log n)$ preprocessing time and $O(n^2)$ space which allows you to navigate a balanced binary search tree corresponding to any angle in $O(\log n)$ time (plus whatever time your query takes to look at stuff in the searc...
In my reference, [Exercise 0.4(e), Algorithms by Sanjoy Dasgupta, Christos H. Papadimitriou, and Umesh V. Vazirani][1], it is given that $$ \begin{bmatrix}F_n\\F_{n+1}\end{bmatrix}=\begin{bmatrix}0&1\\1&1\end{bmatrix}^n\begin{bmatrix}F_0\\F_1\end{bmatrix} $$ Prove that the running time of $fib3$ is $\mathcal{O}(M...
Consider the following algorithm: We are given a planar graph G. We initialise a set of vertices S to an empty set. We randomly pick a vertex v in G and insert it in S. Now we keep including in S vertices from the neighbourhood of S such that the vertex we include is adjacent to exactly one vertex in S. We stop expandi...
Number of "one neighbourhood" search trees in a graph
|algorithms|graph-traversal|
Consider the following algorithm: We are given a planar graph $G$. We initialise a set of vertices $S$ to an empty set. We randomly pick a vertex $v$ in $G$ and insert it in $S$. Now we keep including in $S$ vertices from the neighbourhood of $S$ such that the vertex we include is adjacent to exactly one vertex in $S$....
This is might not be exactly what you are looking for, but you can build a data structure with $O(n^2\log n)$ preprocessing time and $O(n^2)$ space which allows you to navigate a balanced binary search tree corresponding to any angle in $O(\log n)$ time (plus whatever time your query takes to look at stuff in the searc...
For every position of the left pointer, there is a *unique position* of the right pointer such that the sum exceeds or equals $K$ and moving the right pointer to the left makes the sum smaller than $K$. E.g. $2,5,6,8,11,15,21$, target sum $14$. We show the unique right positions for increasing left positions: $\m...
null
null
> Find the equivalence classes of a nerode theorem and use equivalence > classes to construct a reduced DFA for the following language: > $^+(+)^*$ The answer: $,^+,^+^∗+^+^+,(+)Σ^∗+⋅(+)Σ^∗$ I figured that the minimal base for the language is $a^+$ and for the $^+^∗+^+^+$ its just multiplying the expression wi...
Regular expression - Find the equivalence classes of Nerode theorem
|regular-languages|automata|regular-expressions|
Given: A planar undirected connected graph $G$ in which degree of every vertex is $2$ or more. Fact: A planar graph can have multiple planar embeddings. Question: Give an efficient algorithm to find the set $S$ of face cycles corresponding to any one of the planar embeddings. We do not care about from which spec...
One frequent characterisation of the storage for the balance information for an *AVL tree node* (henceforth *node*) is *2 bits*: either for *balance factors* (differences between children's heights) of -1, 0, or 1, or *leftIsTaller*&*rightIsTaller*. More than half the nodes being leaves, it is possible to redu...
null
null
null
null
null
Given: A planar undirected connected graph $G$ in which degree of every vertex is $2$ or more. Fact: A planar graph can have multiple planar embeddings. Question: Give an efficient algorithm to find the set $S$ of face cycles corresponding to any one of the planar embeddings. We do not care about from which spec...
Given: A planar undirected connected graph $G$ in which degree of every vertex is $2$ or more. Fact: A planar graph can have multiple planar embeddings. Question: Give an efficient algorithm to find the set $S$ of face cycles corresponding to any one of the planar embeddings. We do not care about from which spec...
Consider the following algorithm: We are given a planar graph $G$. We initialise a set of vertices $S$ to an empty set. We randomly pick a vertex $v$ in $G$ and insert it in $S$. Now we keep including in $S$ vertices from the neighbourhood of $S$ such that the vertex we include is adjacent to exactly one vertex in $S$....
I have read that a decrease in response time does not necessarily entail an increase in throughput, but I'm struggling to understand the exact way that this can happen. What I'm imagining is a server receiving requests from several different connected devices. Say computer `A` sends a request and the server starts wo...
Throughput and response time
|computer-networks|
null
null
In everything which follows I assume general position of the points (no 3 colinear points), mostly for simplicity. This is might not be exactly what you are looking for, but you can build a data structure with $O(n^2\log n)$ preprocessing time and $O(n^2)$ space which allows you to navigate a balanced binary search ...
When dealing with a Recursive Backtracking Algorithm what are the ways to speed it up and what computational hardware is involved? I'm assuming from ignorance that everything is done by the CPU so the only thing that comes to mind to make it faster would be early exits, multithreading or quantum computing. Is tha...
Recursive Backtracking Algorithm
|algorithm-analysis|backtracking|
Is there any algorithms like Reed Solomon that work for a stream of unknown data? The stream is finite but size is unknown until the stream ends. I found some information about sliding window reed-solomon but that's pretty much it.
Error correcting codes for stream of unkown size
|error-correcting-codes|online-algorithms|
Good day. Some time ago I found a page on Wiki about Heap's algorithm for permutations. [Here it is](https://en.wikipedia.org/wiki/Heap%27s_algorithm). Original algorithm can be written as next (copy from Wiki): ``` procedure generate(k : integer, A : array of any): if k = 1 then output(A) else ...
Proof of correctness of some optimization of Heap's algorithm for producing permutations
|algorithms|correctness-proof|permutations|
In what follows, $r \in \mathbb{N}$ is not necessarily prime. $\mathbb{Z}_r$ is shorthand for $\mathbb{Z}/r\mathbb{Z}$. Given a set of $h$ hyperplanes $A \vec x = b \mod r$, we can check whether the union of the hyperplanes equals the entirety of $\mathbb{Z}_r^n$ in $O(r^n \text{poly}(r,n,h))$ time by just plugging ...
Algorithm for checking whether a set of hyperplanes covers $\mathbb{Z}_r^n$
|algorithms|linear-algebra|modular-arithmetic|
Good day. Some time ago I found a page on Wiki about Heap's algorithm for permutations. [Here it is](https://en.wikipedia.org/wiki/Heap%27s_algorithm). Original algorithm can be written as next (copy from Wiki): ``` procedure generate(k : integer, A : array of any): if k = 1 then output(A) else ...
Consider the following planar graph $G$. There are $n+2$ vertices: $\{x,y,u_1,\dotsc,u_n,v_1,\dotsc,v_n\}$. The edge set is $\{(x,y),(x,u_1),\dotsc,(x,u_n),(y,v_1),\dotsc,(y,v_n),(u_1,v_1),\dotsc,(u_n,v_n)\}$. Suppose your algorithm initially picks $x$ and $y$ in $S$. Then, the algorithm can construct $2^n$ possible...
Consider the following planar graph $G$. There are $n+2$ vertices: $\{x,y,u_1,\dotsc,u_n,v_1,\dotsc,v_n\}$. The edge set is $\{(x,y),(x,u_1),\dotsc,(x,u_n),(y,v_1),\dotsc,(y,v_n),(u_1,v_1),\dotsc,(u_n,v_n)\}$. Suppose your algorithm initially picks $x$ and $y$ in $S$. Then, the algorithm can construct $2^n$ possible...
Ways to speed up a Recursive Backtracking Algorithm
null
The idea is to pick a problem category in Co-NP, where the correct answer is hard to verify because of circuit complexity, express it as 1-in-k SAT formula, and show there also exists a short certificate, whose length in bits is exactly twice the number of clauses. It might be true or false that all of Co-NP problems h...
There shouldn't be a pseudopolynomial-time algorithm; the problem is NP-hard even if all values are given in unary. We can reduce from the $\textsf{Connected Vertex Cover}$ problem in which we need to decide whether a graph has a connected subgraph of at most $k$ vertices touching all edges. This is NP-hard by a simple...
Good day. Some time ago I found a page on (en.) wikipedia about Heap's algorithm for permutations. [Here it is](https://en.wikipedia.org/wiki/Heap%27s_algorithm). Original algorithm can be written as next (copy from (en.) wikipedia): ``` procedure generate(k : integer, A : array of any): if k = 1 then ...
Can Rural Postman Problem with arbitrary start and end be reduced to Rural Postman Problem with single depot node? The rural postman problem is: *Given a MultiDiGraph $G=(V,E)$, a subset of vertices $A$ must be traversed. The path must start and end at the depot node. Find the shortest of all such paths.* I...
Can Rural Postman Problem with arbitrary start and end be reduced to Rural Postman Problem with single depot node?
|graph-traversal|weighted-graphs|eulerian-paths|
Can Rural Postman Problem with arbitrary start and end be reduced to Rural Postman Problem with single depot node? The rural postman problem is: *Given a MultiDiGraph $G=(V,E)$, a subset of vertices $A$ must be traversed. The path must start and end at the depot node. Find the shortest of all such paths.* I...
Can Rural Postman Problem with arbitrary start and end be reduced to Rural Postman Problem with single depot node? The rural postman problem is: *Given a weighted MultiDiGraph $G=(V,E)$, a subset of vertices $A$ must be traversed. The path must start and end at the depot node. Find the shortest of all such pat...
Can Rural Postman Problem with arbitrary start and end be reduced to Rural Postman Problem with single depot node? The rural postman problem is: *Given a weighted MultiDiGraph $G=(V,E)$, a subset of edges $A$ must be traversed. The path must start and end at the depot node. Find the shortest of all such paths....