instruction
stringlengths
0
29.8k
⌀
Prove that a language does not many one reduce to its complement
|turing-machines|computability|undecidability|
I have a graph data structure that has some source points (the red ones) and some destination points (the blue ones). I want to find the shortest path from every source point to its nearest destination point, **or to its nearest source point that is already connected to a destination point by a shortest path**. Plea...
Chapter **2.3.2 Analysing divide-and-conquer algorithms** of *Introduction to Algorithms*, fourth edition, by CLRS, says the following: > A recurrence for the running time of a divide-and-conquer algorithm falls out from the three steps of the basic method. As we did for insertion sort, let $T(n)$ be the worst-case ...
Divide-and-Conquer Algorithms: What exactly is $a$ and $b$ here?
|algorithms|mergesort|
In fact, $a$ is the branching factor (the number of subproblems) and $n/b$ means that each subproblem has size $n/b$. For example, if you do matrix multiplication with a recurrence relation of $T(n) \leq 7T(n/2) + n$, then you branch into 7 subproblems, each of size half. Meaning that at depth $j$ in the recursio...
I have a graph data structure that has some source points (the red ones) and some destination points (the blue ones). I want to find the shortest path from every source point to its nearest destination point, **or to its nearest source point that is already connected to a destination point by a shortest path**. Plea...
Of course, thanks to symmetry, we still achieve a linear time complexity using the modified Knuth-Morris-Pratt algorithm. In general, we can apply symmetries to lots of situations. - For example, you could switch the source and the sink of a flow network with the direction of all edges reversed. - For example, y...
null
null
this question is related to [this](https://cs.stackexchange.com/questions/154852/can-you-solve-the-kinds-of-tms-problem) question but it's different there are 3 kinds of TMs 1. a Halting TM on all inputs prints finitely many symbols on it's output tape and halts 2. a Circle-free TM on all inputs prints infinitely ...
Can you solve the "Crashy TMs" problem?
Chapter **2.3.2 Analysing divide-and-conquer algorithms** of *Introduction to Algorithms*, fourth edition, by CLRS, says the following: > A recurrence for the running time of a divide-and-conquer algorithm falls out from the three steps of the basic method. As we did for insertion sort, let $T(n)$ be the worst-case ...
There is no meaning in $A \Leftrightarrow B \Leftrightarrow C$ seen as a ternary operator. (By the way, how did you compute that truth table ??) After placing parenthesis, the expression can be understood as "one variable is true and the other two equal, or that variable is false and the other two different". In all...
There is no meaning in $A \Leftrightarrow B \Leftrightarrow C$ seen as a ternary operator. (By the way, how did you compute that truth table ??) After placing parenthesis, the expression can be understood as "one variable is true and the other two equal, or that variable is false and the other two different". In all...
null
null
Enumerator programs appear quite often in even an elementary computer science textbook without a formal definition. It does not seem to fit the standard definition of a computable function (through mu recursion, Turing machines or lambda calculus), which takes a single input and a single output. What's a standard li...
How are enumerator programs formally defined?
|turing-machines|computability|
Your question is similar to [the previous one][1] if you had pondered about it. I wonder if you paid attention to my last comment about Rice's theorem and my [last sentences in the answer][2] or not, but to help you I rewrite Rice's theorem statement [from here][3] (Also you can read about this theorem in almost all c...
Can you find a sometimes effective solution for the "Crashy TMs" problem?
Show that the formula $\bigcap_{i=1}^n (X_i \leftrightarrow Y_i)$ cannot have an equivalent disjunctive normal form with less than $2^n$ clauses. I am puzzled on what approach to take -- whether to consider the equivalent boolean functions or some depth trees or some specific example of $X_i$-s and $Y_i$-s in order ...
Minimum DNF length of a conjuction of equivalences
|logic|first-order-logic|formal-methods|normal-forms|
I am studying the idea of *heuristics* in search algorithms, and the [$A^*$ search algorithm][1] in particular. I am told the following: > Greedy search minimises estimated path-cost to goal. > - But it's neither optimal nor even always complete. > > Uniform-cost search minimises path-cost from the start. > - C...
How is this "pathmax modification," $f(n^\prime) = \max(g(n^\prime) + h(n^\prime), f(n))$, useful?
|algorithms|search-algorithms|heuristics|a-star-search|
I am studying the idea of *heuristics* in search algorithms, and the [$A^*$ search algorithm][1] in particular. I am told the following: > Greedy search minimises estimated path-cost to goal. > - But it's neither optimal nor even always complete. > > Uniform-cost search minimises path-cost from the start. > - C...
I am working on parameterized complexity and started exploring on various structural parameters. The problem I am working on is known to be W[1]-hard parameterized by treewidth of the input graph and I am wondering if there is any known relationship between treewidth and maximum degree of the input graph. Could anyone ...
Relationship between the parameters tree width and the maximum degree
|np-hard|parameterized-complexity|
I am working on parameterized complexity and started exploring on various structural parameters. The problem I am working on is known to be W[1]-hard parameterized by treewidth of the input graph and I am wondering if there is any known relationship between treewidth and maximum degree of the input graph. Could anyone ...
There are no direct relation. - The $n$-star (vertices $\{0,\dots,n\}$ and edges $(0,i)$ for $i>0$) has maximum degree $n$ and treewidth $1$. - The $n \times n$-grid has maximal degree $4$ and treewidth $n$. Granted, if your maximal degree is $2$ then the graph is a union of trees and cycles and hence has tree...
Looking at the tree on the left it seems that the triangles represent leaves of the avl tree. To arrive at the balancing of -2 besides the node y the right subtree must have 2 nodes while the left subtree has a maximum of 4 nodes. Thus 2-4 = -2. However what does the h indicate? [![avl tree][1]][1] [1]: ht...
What does h indicate in this diagram of avl trees?
|avl-trees|
It is probably the height of the subtrees, i.e. the length of a longest path from the root to a leaf. Doing the balancing leaves us with a tree of height $h+2$ where we started with height $h+3$.
The parameters are independent. However, combining both parameters yield some interesting more restrictive parameters, where some hard problems become FPT. First note that Graphs of bounded path width and bounded degree have bounded **cut-width**. The other direction is clearly true, since both parameters are (up to...
Suppose we modify the Knuth-Morris-Pratt string-matching algorithm to scan the pattern right-to-left a la Boyer-Moore, and consequently apply the shift rule on the right side of the cursor instead of the left side. The quantity $\text{sp}_i(P)$ is now defined as the length of the longest proper prefix-suffix of $P[i\do...
I am studying the concept of **heuristics** in search algorithms, and the [$A^*$ search algorithm][1] in particular. I am told the following: > Greedy search minimises estimated path-cost to goal. > - But it's neither optimal nor even always complete. > > Uniform-cost search minimises path-cost from the start. ...
**The problem:** Given a set of measurements $x_1, x_2, ..., x_n$ and corresponding labels $y_1 <= y_2 <= ... <= y_n$ that designate the desired ranking, count the number of pairs that are actually ranked correctly by $x$. In other words, compute $$ R((x_k, y_k)_{k=1}^n) = \sum_{i \in 1,...,n-1} \sum_{j \in i+1,...
Efficiently counting correctly ranked pairs
|algorithms|
There are no direct relation. - The $n$-star (vertices $\{0,\dots,n\}$ and edges $(0,i)$ for $i>0$) has maximum degree $n$ and treewidth $1$. - The $n \times n$-grid has maximal degree $4$ and treewidth $n$. Granted, if your maximal degree is $2$ then the graph is a union of trees and cycles and hence has tree...
null
I have a graph data structure that has some source points (the red ones) and some destination points (the blue ones). I want to find the shortest path from every source point to its nearest destination point, **or to its nearest source point that is already connected to a destination point by a shortest path**. Plea...
null
I have a graph data structure that has some source points (the red ones) and some destination points (the blue ones). I want to find the shortest path from every source point to its nearest destination point, **or to its nearest source point that is already connected to a destination point by a shortest path**. Plea...
null
I found this PDA online that accepts all non-palindromes over {0,1}. However, I can't seem to understand how it would accept, say "01011", and not accept "101101". Can someone help me understand how "01011" reaches the final state, and why 101101 doesn't by running through the states with me? [![PDA for the language...
Understanding this PDA for non-palindromes over {0,1}
|context-free|pushdown-automata|
I found this PDA online that accepts all non-palindromes over {0,1}. However, I can't seem to understand how it would accept, say "01011", and not accept "101101". Can someone help me understand how "01011" reaches the final state, and why "101101" doesn't by running through the states with me? [![PDA for the langua...
I have a graph data structure that has some source points (the red ones) and some destination points (the blue ones). I want to find the shortest path from every source point to its nearest destination point, **or to its nearest source point that is already connected to a destination point by a shortest path**. Plea...
For the given figure, let's consider vertex v3. For v3, v0 has a higher partial order,v1 & v2 has the same partial order, and v4 & v5 have lower order than v3, e.g., higher: {v0}, same: {v1,v2} and lower: {v4, v5}. I am looking for an algorithm to recognize these three sets. Is there any proven algorithm to find them? ...
Is there any Algorithm to check a vertex\node's partial order in terms of of other vertices\nodes for a given graph?
|algorithms|graphs|partial-order|topological-ordering|
You can solve this in three stages, using a [shortest-path algorithm](https://en.wikipedia.org/wiki/Shortest_path_problem) followed by a [minimum spanning arborescence algorithm](https://stackoverflow.com/q/21991823/781723). Notation: Let $G$ be the original graph, with one vertex per point and the weight of each ed...
Is there any Algorithm to check a vertex\node's partial order in terms of other vertices\nodes for a given graph?
I am assuming that you're graph $G$ is a DAG. Let $v$ be your reference vertex. Perform a DFS starting at $v$. All vertices reachable from $v$ must have a lower order from $v$. Then reverse the graph, and perform another DFS in this reversed graph starting at $v$. All vertices reachable from $v$ must have a higher orde...
I am assuming that you're graph $G$ is a DAG. Let $v$ be your reference vertex. Perform a DFS starting at $v$ to find all vertices reachable from $v$. These vertices must have a lower order from $v$. Then reverse the graph, and perform another DFS in this reversed graph starting at $v$. All vertices reachable from $v$ ...
[![Two FAs][1]][1] I am still quite confused on how to properly handle in answering the `intersection and equality of two FAs` in terms of table form and manipulating its transformation. It is a bit challenging at times when I encounter new FAs to compare. It would help a lot if there would be a proper way and tip...
How to find the intersection of two FAs and then check if two FAs are equal?
|automata|finite-automata|equality|finite-sets|finite-model-theory|
So I have a problem that is ,I have an integer array and first I define an interval as a good interval iff, within the interval every integer appears an even (including zero) number of times. I want to find the number of good intervals in a given integer array. For example, if array = [7, 7, 1, 5, 5, 1], the balanced i...
Using Hashing to count the number of occurrences of a pattern within an integer array
|optimization|integers|hashing|intervals|
So I have a problem that is ,I have an integer array and first I define an interval as a good interval iff, within the interval every integer appears an even (including zero) number of times. I want to find the number of good intervals in a given integer array. For example, if array = [7, 7, 1, 5, 5, 1], the good inter...
null
A company is able to earn `x` dollars per day without any machines. However, there are `n` machines available for purchase. The `i`-th (`0<=i<n`) machine costs `v[i]` and can bring an extra profit of `m[i]` per day to the company. Each machine can be purchased only once, but the company can buy multiple machines on the...
Maximum Accumulated Balance after Purchasing Machines
|dynamic-programming|greedy-algorithms|
The parameters are independent. However, combining both parameters yield some interesting more restrictive parameters, where some hard problems become FPT. First note that Graphs of bounded path width and bounded degree have bounded **cutwidth**. The other direction is clearly true, since both parameters are (up to ...
null
I am currently studying the concept of **heuristics** in search algorithms. I recently asked [this question][1] about the so-called "pathmax modification," $f(n^\prime) = \max(g(n^\prime) + h(n^\prime), f(n))$, and how it is useful. The [user Pål GD][2] commented with the following: > The heuristic will be monotone,...
If the heuristic $h(n)$ is the estimated cost from node $n$ to the goal, then why would we want a heuristic that has a greater cost?
|algorithms|search-algorithms|heuristics|
I have the language $L = \{ 0^{2l} 1^m | l,m >= 0 \} \ where \ \Sigma= \{0,1\} $ which I am trying to find the class of language for, e.g. not context-free, context-free, regular. By this notion I assume $L$ is context-free and has some pumping length $p$, and I will use the pumping lemma. $w = 0^{2p}1^p$ and c...
Determining class of language with pumping lemma?
|formal-languages|context-free|pumping-lemma|
Your language is regular. A regular expression is e.g. $(00)^\ast1^\ast$. The numbers $l$ and $m$ are not in any relation to each other. You just have an even number of $0$s followed by an arbitrary number of $1$s.
I am working on the decision version of an NP-complete problem. The problem is known to be fixed parameter tractable(FPT) with respect to the solution size $k$ as the parameter. If I consider another parameter (e.g. $p$), then which among the two following statements holds true? 1. if $p \leq f(k)$, since the pro...
Tractability w.r.t. multiple parameters
|np-hard|parameterized-complexity|
I am currently studying the concept of **heuristics** in search algorithms. I recently asked [this question][1] about the so-called "pathmax modification," $f(n^\prime) = \max(g(n^\prime) + h(n^\prime), f(n))$, and how it is useful. The [user Pål GD][2] commented with the following: > The heuristic will be monotone,...
This problem can be easily solved by minimum spanning tree (in time $O(n\log n + m)$). Let $S$ be the set of sources and $T$ the set of destinations. Start by adding a vertex $u$ and make it adjacent to all destination vertices (with zero weight). Compute a minimum spanning tree of the resulting graph. You can choo...
I am currently studying the concept of **heuristics** in search algorithms. I recently asked [this question][1] about the so-called "pathmax modification," $f(n^\prime) = \max(g(n^\prime) + h(n^\prime), f(n))$, and how it is useful. The [user Pål GD][2] commented with the following: > The heuristic will be monotone,...
Remember that the heuristic is always _under-estimating_ the cost from a node to the target, which means that a higher cost (closer to the true value) is always a more accurate cost. For example, suppose that your landscape is a grid (like Manhattan) with some potential road-blocks. Then you can let the heuristic f...
null
Generally, **if** 1. you can solve a problem in time $f(k) \cdot n^{O(1)}$, for a monotone $f$, 2. and you know that $g(p) \geq k$ **then** certainly you can solve the problem in time $f(g(p)) \cdot n^{O(1)}$. If $\text{VC} \geq \text{TW}$ and you can solve a problem in time $f(\text{TW}) \cdot n^{O(1)}$ time...
|graphs|np-hard|parameterized-complexity|
I suggest you take a look at the concepts of "Cycle Basis" and "Minimum Cycle Basis". Each is described in simple terms by NetworkX's documentation as below: [**Cycle Basis.**][1] A basis for cycles of a network is a minimal collection of cycles such that any cycle in the network can be written as a sum of cycles ...
I suggest you take a look at the concepts of "Cycle Basis" and "Minimum Cycle Basis". Each is described in simple terms by NetworkX's documentation as below: [**Cycle Basis.**][1] A basis for cycles of a network is a minimal collection of cycles such that any cycle in the network can be written as a sum of cycles ...
null
How to prove that for any words $w_1, ..., w_n$ on alphabet $\{0,1\}$ the regular expression $w_1^*w_2^*...w_n^*$ doesn't represent language $\{0,1\}^*$?
How to prove that for any words $w_1, ..., w_n$ of alphabet $\{0,1\}$ regular expression $w_1^*w_2^*...w_n^*$ doesn't represent language $\{0,1\}^*$?
|regular-languages|regular-expressions|
null