instruction stringlengths 0 29.8k ⌀ |
|---|
|complexity-theory|combinatorics|complexity-classes|subset-sum| |
null |
Consider a Turing machine with alphabet $\Sigma$, states $Q$, a transition function $\delta$ and a tape with $k$ cells.
The configurations of this Turing machine (contents of the tape, current state, position of the read-write head) form a finite set $\Sigma ^k \times Q \times [k-1]$ if $[k-1] = \{n \in \mathbb N : ... |
I have in the lectures a sentence in English, which I have to translate to First Order Logic.
> Someone who loves all animals loves all humans.
Textbook solution:
> ∀x.(is_human(x) ⇒ is_animal (x))
>
> ⇒
>
> ∀y.(is_human(y) ∧ ∀z.(is_animal(z) ⇒ loves(y, z)) ⇒ ∀z.(is_human(z) ⇒ loves(y, z))))
My solutio... |
'Someone' in first order logic |
The main issue here is that *someone* is ambiguous. You are correct in that usually, it translates to an existential quantifier. But it doesn't always.
To find an example, I Googled for "someone who * will also", which produced [this page][1], with the sentence:
> Someone who really respects you will also respect... |
null |
null |
Your reasoning looks on the right track. However, somewhere along the way, it loses track of the correct parity of numbers and the exact number of nodes that have $1$ child. More case-by-case analysis may be in need.
------
Here is a simpler and clearer way with combinatorics flavor, i.e., using double counting t... |
The term *external* node is used as a synonym for a *leaf* node in the following.
A binary tree shall be called proper if each node has either zero or two children. If it is not proper, it shall be called improper.
I need to determine the maximum number of external nodes in an *improper* binary tree. Here is my cur... |
So I have this Recursive Descent Parser which outputs a Syntax Tree for arithmetic expressions.
[![parse tree][1]][1]
While doing some reading, I learned that LL(1) grammars have a lookahead of 1 - I remembered using a lookahead so I grepped for it. But instead of finding it in my parser, I found it in the lexer.... |
Should I lookahead in the lexer or parser? |
|compilers|parsers|lexical-analysis| |
"The right way to do things" depends on the specifics of the language.
The lexical syntax of most modern programming languages uses what is known as the [maximal munch rule][1], which states that given more than one possibility as to what the next lexeme could be, choose the one that consumes more of the input. This... |
null |
null |
null |
null |
I've been trying to solve this problem:
> Given a minimum heap $H$, which contains $n$ elements, where each of its keys contain natural numbers, as well as $k\in\mathbb{N}$.
>
> Add the value $k$ to each of the keys on the left from the root, (Which means to add to each element in the heap which has an index of the... |
Minimum Heap - Add k to all left keys and heapify efficiently |
|algorithms|complexity-theory|data-structures|heaps| |
null |
null |
null |
How can I prove that if a polynomial of |
How to prove that a po |
null |
How can I prove that if $T(x)$ is a polynomial of degree $n$ then $T(x) = \Theta(x^n)$. |
How to prove that a polynomial of degree n is θ(x^n) |
null |
null |
I've been trying to study some graph algorithms and, as part of it, prove a bunch of graph theorems in order to practice my ability to do theoretical work with graphs.
Specifically, I've been trying to prove that given a directed graph $G$, the minimal (in terms of vertex count) non-empty subset of vertices with no ... |
(Directed) Graphs: Minimal Vertices Subset With No Outgoing Edges |
|graphs|proof-techniques|directed-graphs|connected-components| |
The problem:
Given an undirected graph G = {V, E}, a source-vertex s, and each vertex having a "capacity" between 0 and |V|, is there a tree which covers all vertices and does not extend from a vertex more times than its capacity allows, while also not covering every edge? Demonstrate that it is NP-complete.
An exa... |
Showing NP-completeness of a graph problem with vertex capacities |
|graphs|np-complete|reductions|np| |
I've been trying to study some graph algorithms and, as part of it, prove a bunch of graph theorems in order to practice my ability to do theoretical work with graphs.
Specifically, I've been trying to prove that given a directed graph $G$, the minimal (in terms of vertex count) non-empty subset of vertices with no ... |
I would be very grateful if someone can clarify a little bit about the Dancing tree data structure that the Reiser4 filesystem uses. It's a presentation topic that I picked, however, there seems to be little resource about it. The only things that I could found are:
- Reiser4's description of Dancing Tree: http://web... |
Questions about the Dancing Tree data structure |
|data-structures|trees|filesystems|b-tree| |
Given the following grammar:
1. S -> A
2. A -> AB
3. A -> ϵ
4. B -> aB
5. B -> b
Check whether it is CLR(1) or not.
I have drawn the canonical itemsets as well as the parse table. But I'm not sure whether it is actually correct or not. I have tried searching for some similar examples that have epsilon ... |
How to handle epsilon production in CLR(1) parsing? |
|compilers| |
null |
When applying the DC3/Skew algorithm to the string **yabadabado**, I can't quite get it to sort correctly. This issue happens in other cases, but this is a short example to show it.
This first table is for reference:
[![enter image description here][1]][1]
These are the triples of R<sub>12</sub>
[![enter imag... |
DC3/Skew Suffix Array Algorithm doesn't work for specific cases |
|algorithms|strings|substrings|suffix-array| |
There is no wonder you end up feeling stuck. Assume $G$ has at least one vertex. The second case, "there is no such SCC with an in-degree of zero" does not exist.
Recall if each strongly connected component (SCC) of $G$ is contracted to a single vertex, the resulting graph $\mathcal C(G)$, the condensation of G i... |
null |
There is no wonder you end up feeling stuck. Assume $G$ has at least one vertex. The second case, "there is no such SCC with an in-degree of zero" does not exist.
Recall if each strongly connected component (SCC) of $G$ is contracted to a single vertex, the resulting graph $\mathcal C(G)$, **the condensation of G... |
You can transform each instance of the hamiltonian cycle problem (finding a cycle that visits each vertex exactly once) into an instance of your problem.
Given a hamiltonian cycle problem with a graph $G=(V,E)$, you can apply the reduction described <a href="https://math.stackexchange.com/a/1290804/1127243">here</a>... |
I'm preparing for my exam and I got stuck on the following problem:
The gardening problem:
> We have access to a set of different types of seeds and a number of plant pots.For each plant pot, there is a limit to how many seeds can be planted in that particular pot.
>
>In addition, there are seeds that cannot be... |
null |
I've been trying to study some graph algorithms and, as part of it, prove a bunch of graph theorems in order to practice my ability to do theoretical work with graphs.
Specifically, I've been trying to prove that given a directed graph $G$, the minimal (in terms of vertex count) non-empty subset of vertices with no ... |
There is no wonder you end up feeling stuck. Assume $G$ has at least one vertex. The second case, "there is no such SCC with an out-degree of zero" does not exist.
Recall if each strongly connected component (SCC) of $G$ is contracted to a single vertex, the resulting graph $\mathcal C(G)$, **the condensation of ... |
null |
Assuming $\mathsf{P} \neq \mathsf{NP}$, then all NP-complete languages are countably infinite. I know not all subsets are NP-complete, but I am wondering if there's a simple proof that every NP-complete language can be partitioned into two subsets $X,Y$ such that both $X$ and $Y$ are NP-complete. |
If P != NP, can every NP-complete language be partitioned into two NP-complete subsets? |
|complexity-theory| |
null |
Tricky. If you can enumerate all the possible instances of your problem N, then you divide them into "even" and "odd" instances. You could now have one problem saying NOdd asking "Is I is an odd instance of N, and does N answer YES" and a problem NEven asking "Is I an even instance of N, and does N answer YES".
Sou... |
null |
null |
Using the algorithm provided by [this paper][1], they said that:
>The algorithm defines a single phase of the local max algorithm. Each step of the phase takes at most O(log(m + n)) = O(logn) time and O(n + m) work in the CREW PRAM model. Over O(logm) phases, each with geometrically decreasing number of edges, th... |
Analyzing Parallel Matching Algorithm - Why it takes O(n+m) time and work? |
|algorithms|distributed-systems|weighted-graphs|parallel-computing|matching| |
Let $P$ be a partial order on $X.$ Does the relation $E(P)=$ { $(x,y)\in (X\times X)\setminus P:P$ $\cup$ { $(x,y)$ } is a partial order on $X$ } have a name? If not, what's a good thing to call it? |
relation based on a given partial order - does it have a name? |
|terminology|partial-order| |
The BFS algorithm still works with some changes. You'd basically have to pad an extra character in all the places. For instance, if there's no word of the same length to move from the word "hot", you check for words of length 4 characters. For this, you'd have to check all 26 characters in 4 positions. `[x]hot`, `h[x]o... |
so this is my question:-
If I manage to find a vertex cover which has ....let's say 100 more vertex than the minimum vertex cover. Can I find the minimum vertex cover in polynomial time from this vertex cover provided?
Here, vertex cover is general vertex cover for any random graph.
Thank you. |
Can I find the smallest vertex cover |
|algorithms|decision-problem|vertex-cover| |
null |
so this is my question:-
If I manage to find a vertex cover which has ....let's say 100 more vertex than the minimum vertex cover. Can I find the minimum vertex cover in polynomial time from this vertex cover?
Here, vertex cover is general vertex cover for any random graph.
Thank you. |
$\varepsilon $ is a representation of an empty string. Since it derives literally nothing, it is as good as having scanned the complete production, with the corresponding item set $A\rightarrow \cdot$ and would trigger a $reduce$ action on respective lookahead. |
I think in your book results, first of all they reduce to FA and then they convert to DFA, just like NDFA to DFA.
So that in the second picture actual comes like this. |
I think in your book results, first of all they reduce to FA and then they convert to DFA, just like NDFA to DFA.
So that in the second picture actual result comes like this. |
I think in your book results, first of all they reduce to FA and then they convert to DFA, just like NDFA to DFA.
So that in the second picture actual result comes like this, but the forget to mentioned some input state. |
I think in your book results, first of all they reduce to FA and then they convert to DFA, just like NDFA to DFA.
So that in the second picture actual result comes like this, but they forget to mentioned some input state in q_f and q_3. |
I am trying to grasp the concept of triple sat compared to 3Sat. I understand that 3Sat has 3 literals for each for each clause. ${Triple-Sat} = \{ \phi | \phi $ has at least three satisfying assignments $\}$. Im just not exactly sure what the difference is between them. |
what is the difference between triple sat and 3Sat? |
|complexity-theory|computation-models| |
Wondering which approach is faster in terms of time complexity. In short, is having a single loop that clears out the vector every time there's a difference lesser than the minimum so far faster than having two separate loops: first determines the minimum difference, second appends the corresponding elements with minim... |
Determining a faster/better approach for finding a pair with minimum difference in an array |
|time-complexity|c++| |
I don't see a connection between the two problems.
3SAT restricts the form or the formulas. A 3SAT formula can have any number of satisfying assignments. 3SAT asks for satisfiability (does there exist a satisfying assignment?)
Triple Sat is independent of the form of the formula, and simply asks a different quest... |
I'm trying to apply the master method (https://en.wikipedia.org/wiki/Master_theorem_(analysis_of_algorithms)) to the following recurrence:
$T(n) = 2*T(2n)+n$
We have $a=2$ and $b=1/2$.
Also,
$f(n)=n$
and
$n^{log_b a} = n^{log_{1/2} 2} = n^{-1}$ since $log_{1/2} 2 = -1$.
So, case 3 applies since $f(n) =... |
Does T(n) = 2*T(2n) + n apply to Master method? |
|algorithms|time-complexity|algorithm-analysis|recurrence-relation|master-theorem| |
null |
From wikipedia
"Here $n$ is the size of an input problem, $a$ is the number of subproblems in the recursion, and $b$ is the factor by which the subproblem size is reduced in each recursive call $(b>1)$"
<hr>
So no. Master theorem can not be used to solve the given recurrence. |
I'm preparing for my exam and I got stuck on the following problem:
The gardening problem:
> We have access to a set of different types of seeds and a number of plant pots.For each plant pot, there is a limit to how many seeds can be planted in that particular pot.
>
>In addition, there are seeds that cannot be... |
I have a large array of bits of length $N$.
The query $f(k, m)$ means "find $kth$ zero in the array and the next $m-1$ zeros after it", $k \in [0, N-1], m \ll N$
Currently I use a segment tree over the bit array and my approasches were:
- use [kth zero search procedure](https://cp-algorithms.com/data_structur... |
Zero sequence query in boolean array |
|time-complexity|range-query|segment-trees| |
The Master Theorem is not deemed to be used with $b<1$. But you can recast the recurrence as
$$T(2n)=\frac12T(n)-\frac n2$$
or
$$T(n)=\frac12T\left(\frac n2\right)-\frac n4.$$
|
Try to copy from SSD disk to HDD disk. What will happen? The connection will follow the slowest part. However, I have perceived network bottleneck. Get 10000 torrents to download "1kb/s". What happens? "Error on the disk".... Cause disk head on plate cannot go in so many different places per second. So, I think that HD... |
null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.