instruction
stringlengths
0
29.8k
⌀
|np-hard|check-my-answer|
$N$ towns are given, which we can get to by passing through the northern and southern gates. If you enter a town through a gate, you have to use another gate to leave the town. The merchant would like to plan his journey in such a way that starting from any town, he visits all towns exactly once and returns to the star...
Finding a Hamiltonian Cycle in a directed graph - graph problem
|algorithms|graphs|python|hamiltonian-path|hamiltonian-circuit|
Your logic isn't sound, because it could be that the minimum hitting set (MHS) problem where there is a unique hitting set is much easier. In general you can't assume a problem is hard because it solves a specific subset of a known hard problem, only if it could solve *all* instances of a known hard problem. But the...
Your logic isn't sound, because it could be that the minimum hitting set (MHS) problem where there is a unique hitting set is much easier. In general you can't assume a problem is hard because it solves a specific subset of a known hard problem, only if it could solve *all* instances of a known hard problem. But the...
I know this is over a year, but just wondering what you came up with? I'm thinking of using a Queue. I would initialize the queue with the known days and amounts and sum the entries. Then with each new day, I would add it to the queue and add the amount for that day to the sum, and then remove an entry from the queu...
null
{"OriginalQuestionIds":[151449],"Voters":[{"Id":91753,"DisplayName":"John L."},{"Id":-1,"DisplayName":"Community","BindingReason":{"DuplicateApprovedByAsker":""}}]}
I am not looking for the complexity of following algorithm but rather _how to think about the problem and calculate complexity of a given solution?_ One way is to perhaps use The Master Method for recursive functions, but that hides the "how?" part. I am trying to get much better at calculating complexities of algo...
null
I have a bipartite graph *G=(U, V, E)* where nodes are numbered (*{Ui, Vj} where i,j=1,2,3,...*), such that edges don't "skip" the *V* vertices. Meaning, if edge *(Ui, Vj)* doesn't exist, neither will edges *(Ui, Vj+1), (Ui, Vj+2), etc.* (all vertices connected to *U1* are at the "first" *V*s, and all vertices connecte...
Split Bipartite Graph
|graphs|bipartite-graph|
$N$ towns are given, which we can get to by passing through the northern and southern gates. If you enter a town through a gate, you have to use another gate to leave the town. The merchant would like to plan his journey in such a way that starting from any town, he visits all towns exactly once and returns to the star...
So I this question was sent to me by a friend and I didn't really ask him about its source so I couldn't provide the source of it. I solved the question and I need to ensure my answer not just for him but also for myself since it's important to me too. ***Question:*** Prove or Disprove: if $L$ is decidable language ...
Disprove: if $L$ is decidable then $Prefix(L)$ is decidable
|turing-machines|undecidability|halting-problem|check-my-answer|
I was asked to show the equality $ RP(1 − 2^{-2^{n}}) = P $, which seems wrong to me (?). The $ \supseteq $ direction is obvious, and I want to show the other direction. My first intuition was to run the algorithm that gives a false negative with probability $ 1-2^{-2^{n}} $ for $ n $ iterations, which will get m...
RP with very small error = P
|computability|probabilistic-algorithms|probabilistic-turing-machines|
null
So I this question was sent to me by a friend and I didn't really ask him about its source so I couldn't provide the source of it. I solved the question and I need to ensure my answer not just for him but also for myself since it's important to me too. ***Question:*** Prove or Disprove: if $L$ is decidable language ...
For discrete, non numerical data, you can use a relation (in the sense of relational database). For numerical data, you can use multivariate interpolators, such as neural nets with overfitting. What you feed to the input of such devices will return as output what was trained on. ---------- Needless to s...
I've been stuck on the following assignment: > Imagine that the following big-O expressions correspond to the worst-case running times of different algorithms, where $n$ denotes the input size and $p$, $q$ and $r$ are potential parameters (for which we assume that $p, q, r \leq n$). Which of these can be made to con...
Smallest parameter set for big-O expression
|complexity-theory|runtime-analysis|big-o-notation|parameterized-complexity|
null
[Alternating Finite Automata][1] is a superset of NFA while being equal in expressive power to NFAs. It is defined by 6-tuple (Q∃, Q∀, Σ, δ, Q0, F) where all outgoing transitions from Q∃ are 'or'ed and that from Q∀ are 'and'ed. Is there an algorithm for converting AFA to ε-NFA, NFA or DFA? I tried searching in Googl...
How to convert AFA to ε-NFA / NFA / DFA?
|regular-languages|automata|finite-automata|
It is correct that if $L$ is decidable language $\text{Prefix}(L)$ may or may not be decidable. ------ The language $L$ given in the question is indeed an example of a decidable language the prefix language of which is undecidable. However, your proof is somewhat specious. Firstly, in order to show $\text{...
The following question was sent to me by a friend and I didn't really ask him about its source so I couldn't provide the source of it. I solved the question and I need to ensure my answer not just for him but also for myself since it's important to me too. ***Question:*** Prove or Disprove: if $L$ is a decidable lan...
Disprove: if L is decidable then Prefix(L) is decidable
It is correct that if $L$ is decidable language $\text{Prefix}(L)$ can be undecidable. The language $L$ given in the question is a concise example of a decidable language the prefix language of which is undecidable. ----- However, your proof is somewhat specious. Firstly, in order to show $\text{Prefix}(L)$ i...
null
This is a rather easy geometry problem. First of all, here's a similar competitive programming problem I solved: https://www.beecrowd.com.br/judge/en/problems/view/1497 This problem called "Hide and Seek" gives you several points where the first 10 are "seekers". Also, several walls are given, represented as s...
I've been stuck on the following assignment: > Imagine that the following big-O expressions correspond to the worst-case running times of different algorithms, where $n$ denotes the input size and $p$, $q$ and $r$ are potential parameters (for which we assume that $p, q, r \leq n$). Which of these can be made to con...
I've been stuck on the following assignment: > Imagine that the following big-O expressions correspond to the worst-case running times of different algorithms, where $n$ denotes the input size and $p$, $q$ and $r$ are potential parameters (for which we assume that $p, q, r \leq n$). Which of these can be made to con...
I am developing a system which performs automated room allotment. We have finite number of rooms, each with varying capacity. Each booking request is also of varying size. The goal here is to minimize number of rooms used and minimize room capacity wasted. Assume bookings cannot share rooms. The only reason why we want...
Allocating m rooms of varying capacity to n booking requests of varying sizes
|optimization|dynamic-programming|optimal-strategy|
null
Here is a simple method to find the parameters that can be fixed so that (the problem whose worst runtime is bounded by) a big $O$-expression becomes fixed parameter tractable. For example, $p^r\sqrt{q}n^2$. Is it FPT if the fixed parameters are $\{p\}$? Just replace $p$ by $3$ and all other parameters by $n$. Yo...
null
Many years ago I was asked for help by a mate who studied economics. His professor had developed a model for work per time: After you perform X units of work, your experience grows, and therefore you can perform one unit of work Y percent faster. And my mate couldn't wrap his head around it. Since you ask about the...
Here is a simple method to find the parameters that can be fixed so that (the problem whose worst runtime is bounded by) a big $O$-expression becomes "tractable", i.e., bounded by some polynomial of the input size $n$. For example, $p^r\sqrt{q}n^2$. Is it tractable if the fixed parameters are $\{p\}$? Just replac...
{"Voters":[{"Id":9753,"DisplayName":"Turbo"}]}
{"Voters":[{"Id":9753,"DisplayName":"Turbo"}]}
{"Voters":[{"Id":9753,"DisplayName":"Turbo"}]}
null
DVR(uses Bellman-Ford algorithm to reach the next hop e. g, RIPv1) and Link state(uses Dijkstra algorithm for finding the shortest path to keep the knowledge of entire topology e. g. OSPF) is the example of dynamic routing protocol. In dynamic routing routers exchanges the routes (routing database) periodically wit...
If we some how transform a Binary Search Tree into a form where no node other than root may have both right and left child and the nodes the right sub-tree of the root may only have right child, and vice versa, such a configuration of BST is inherently sorted with its root being approximately in the middle (in case of ...
I think I have discovered a new sorting algorithm using binary search tree
|sorting|trees|binary-search-trees|
Imagine that we are designing a system in which we have the action to brake or not brake. How can we write an LTL specification that guarantees that we cannot switch between braking and not braking within three time steps?
Switching between doing something and not doing it in $k$ steps in LTL
|linear-temporal-logic|
Switching between doing something and not doing it within $k$ steps in LTL
You can simply require that whenever there is a switch (i.e., the braking status changed from one to another), the status will not change for the next three steps. Technically, let $b$ denote the propositions that brake is on, then we have the following: $$G((\neg b\wedge Xb)\to (XXb\wedge XXXb) )\wedge G((b\wedge X\...
null
Consider a Boolean circuit using (2-input) logical-and, (2-input) logical-or and logical-not as basic components. The depth of the Boolean circuit is the length of the longest path from the input to the output. I wonder if Boolean circuits with a depth Polylog in the number of inputs are sufficient to express any Boole...
Can Boolean circuits of polylog depth represent all Boolean functions?
|circuits|boolean-complexity|
null
Nice work, but not useful because - trees are not really sorted (in the sense of a sorted array) as the nodes may be stored non-contiguously in memory, and you need to follow the links; - any BST *is* sorted because traversing the nodes in infix order gives a sorted list, there is no need to reorganize.
null
I am developing a system which performs automated room allotment. We have finite number of rooms, each with varying capacity. Each booking request is also of varying size. The goal here is to minimize number of rooms used and minimize room capacity wasted. Assume bookings cannot share rooms. The only reason why we want...
As far as I understand pipelining is a way to excecute a instruction every clock cycle. It is a process performed on single cores. My question is how does the control unit handle this, at some point the control unit will have to store results from a completed instruction while simultaneously decode or fetch a new instr...
How is pipelining possible?
|cpu|
I am developing a system which performs automated room allotment. We have finite number of rooms, each with varying capacity. Each booking request is also of varying size. The goal here is to minimize number of rooms used and minimize room capacity wasted. Assume bookings cannot share rooms. The only reason why we want...
null
A $k$-ary circuit of depth $d$ has size at most $k^d$, hence polylog-depth circuits of fan-in $2$ have quasipolynomial size. Thus, the vast majority of Boolean functions cannot be computed by such circuits, as most functions require exponential circuit size $\Omega(2^n/n)$.
You can introduce a network $G_{new}$ such as follows: For each vertex i (or town) in G introduce two vertices $i'$ (for north gate) and $i''$ (for south gate) which are connected to each other; i.e. There exist both arcs $i'i''$ and $i''i'$. Moreover, if we can move between $i$ and $j$ from northern gate of vertex ...
This is a rather easy geometry problem. First of all, here's a similar competitive programming problem I solved: https://www.beecrowd.com.br/judge/en/problems/view/1497 This problem called "Hide and Seek" gives you several points where the first 10 are "seekers". Also, several walls are given, represented as s...
The control unit is split between the pipeline stages. Typical is that there is the front-end which fetches the instruction and decodes what it needs to do. This decoded instruction is sent to the scheduler which then tells the execution units what needs to happen. The passing of information between stages itsel...
What is the definition for the length of a regular expression? This question might sound simple, yet I cannot find a definition. Do I only count letters from the alphabet? Do * and $\cup$ count? For example: let r = $(ab)^*\cup$ $a$. What is $|r|$?
Length of a regular expression
|regular-expressions|
null
I assume, you want to define the length of a regular expression such that you can make statements like: *The Thompson construction creates an NFA from a regular expression with a number of states that is linear in the length of the expression.* In that case, it is crucial to include operator symbols, otherwise the a...
The definition given in [this][1] Textbook says that > A data structure is a way to store and organize data in order to facilitate access and modifications. Again, highlighting key words: > A data structure is a **way to store and organize data** in order to facilitate **access** and **modifications**. ...
Given a graph with $V$ vertices and a set $K$ of $k$ vertices of $G$. Let $c(u)$ be the distance (in BFS-like) of the vertex $u \in V$ to the closest vertex $k \in K$. How to choose the set $K$ such that the maximum $c(u) \forall u \in V$ is minimized? This is like a dominating set, but each vertex covers a range of...
Find a set K of k vertices in a graph such that the distance between any vertex to the closest vertex in K is minimized
|algorithms|time-complexity|
I have a bipartite graph $G=(U, V, E)$ where nodes are numbered $\{U_i, V_j\}$, where $i,j=1,2,3,\ldots$ such that edges don't "skip" the $V$ vertices. Meaning, if edge $(U_i, V_j)$ doesn't exist, neither will edges $(U_i, V_k)$ for all $k>j$ (all vertices connected to $U_1$ are at the "first" $V_s$, and all vertices c...
null
I have a bipartite graph $G=(U=\{U_1, U_2,\cdots\}, V=\{V_1, V_2,\cdots\} , E)$ such that edges don't "skip" the $V$ vertices. Meaning, if edge $(U_i, V_j)$ doesn't exist, neither will edges $(U_i, V_k)$ for all $k>j$. All vertices connected to $U_1$ are at the "first" $V_i$s, and all vertices connected to the last $U_...
|graphs|partitions|bipartite-graph|
There are two conventions I know of. One is defining the size of a regular expression as the size of the binary tree representing the expression. As such, the size of the expression is the total number of symbols in the expression, counting $\emptyset$, $a\in \Sigma$, $*$, $|$ and $\cdot$ (parentheses are not counte...
This problem is at least as hard as the subset sum problem, so it is NP-hard. That means you should not expect any efficient algorithm. One plausible approach is to use integer linear programming. Introduce 0-or-1 variables $x_{q,r}$, where $x_{q,r}=1$ means that room $r$ is assigned to request $q$. Then you can ...
{"Voters":[{"Id":755,"DisplayName":"D.W."}]}
The three languages you ask about are not very interesting: * $L_1$ is famously not context-free; it's usually written as $\{ ww \mid w \in \Sigma^* \}$. Note that the condition $|w_1| = |w_2|$ is obsolete. [Standard entry-level proof techniques](https://cs.stackexchange.com/questions/265/how-to-prove-that-a-langua...
I am developing a system which performs automated room allotment. We have finite number of rooms, each with varying capacity. Each booking request is also of varying size. The goal here is to minimize number of rooms used and minimize room capacity wasted. The only reason why we want to minimize number of rooms used is...
Given a graph with $V$ vertices and $k$, find a set $K$ of $k$ vertices of $G$. Let $c(u)$ be the distance (in BFS-like) of the vertex $u \in V$ to the closest vertex $k \in K$. How to choose the set $K$ such that the maximum $c(u) \forall u \in V$ is minimized? This is like a dominating set, but each vertex covers ...
The construction yields a nondeterministic NFA $A'$ that is equivalent to the original alternating AFA $A$. The states of the new automaton are sets of states of $A$, just as in the classic construction of a deterministic DFA from an NFA. In the new DFA we collect *all* reachable states and accept if one of the stat...
The construction yields a nondeterministic NFA $A'$ that is equivalent to the original alternating AFA $A$. The states of the new automaton are sets of states of $A$, just as in the classic construction of a deterministic DFA from an NFA. In the new DFA we collect *all* reachable states and accept if one of the stat...
null
I have a bipartite graph $G=(U=\{U_1, U_2,\cdots\}, V=\{V_1, V_2,\cdots\} , E)$ such that edges don't "skip" the $V$ vertices. Meaning, if edge $(U_i, V_j)$ doesn't exist, neither will edges $(U_i, V_k)$ for all $k>j$. All vertices connected to $U_1$ are at the "first" $V_i$s, and all vertices connected to the last $U_...