instruction stringlengths 0 29.8k ⌀ |
|---|
A PTIME reduction from $\text{SAT}$ to $\overline{HALT_{TM}}$ operates as follows. On input $\varphi$, the reduction outputs $\langle M, \varphi\rangle$, where $M$ is a constant TM that operates as follows. On input $\varphi$, $M$ goes over all assignments to variables of $\varphi$, and checks whether $\varphi$ is sati... |
A PTIME reduction from $\text{SAT}$ to $\overline{HALT_{TM}}$ operates as follows. On input $\varphi$, the reduction outputs $\langle M, \varphi\rangle$, where $M$ is a constant TM that operates as follows. On input $\varphi$, $M$ goes over all assignments to variables of $\varphi$, and checks whether $\varphi$ is sati... |
Let $T$ be a fixed Turing machine that decides SAT. From $T$ it is easy to construct a Turing machine $T'$ that takes SAT instance $x$ as input and halts iff $T(x)$ rejects.
In other words, given a SAT instance $x$, $x$ is satisfiable iff the pair $\langle T', x \rangle$ is in the complement of the Halting language... |
null |
I am trying to implement a BTree. As far as I understand the height of the Tree the faster the search (This could be wrong and Correct me if it is).
So, far I do not have much code except the following because I cannot decide which method I should choose and Why? I want fast insertion deletion and search.
```
#in... |
How decide whether pre-emptive split or non pre-emptive split and pre-emptive merge or non pre-emptive merge for a BTree? |
|b-tree| |
I am trying to implement a BTree. As far as I understand the height of the Tree the faster the search (This could be wrong and Correct me if it is).
So, far I do not have much code except the following because I cannot decide which method I should choose and Why? I want fast insertion deletion and search.
```
#in... |
I am trying to implement a BTree. As far as I understand the height of the Tree the faster the search (This could be wrong and Correct me if it is).
So, far I do not have much code except the following because I cannot decide which method I should choose and Why? I want fast insertion deletion and search.
```
#in... |
I am trying to implement a BTree. As far as I understand the height of the Tree the faster the search (This could be wrong and Correct me if it is).
So, far I do not have much code except the following because I cannot decide which method I should choose and Why? I want fast insertion deletion and search.
```
#in... |
null |
How I implemented this algorithm in go:
```go
func calcRouteTripSeating(trip Trip) error {
// Flatten all toStops into on array
var toStops []RouteToStop
for i := range trip.Route.Stops {
for j := range trip.Route.Stops[i].ToStops {
toStops = append(toStops, trip.Route.Stops[i].ToStops[j])
}
}
/... |
null |
null |
I am trying to implement a BTree. As far as I understand the lower the height of the Tree the faster the search (This could be wrong, please correct me if it is).
Is *pre-emptive split* with *non-pre-emptive merge* the best or *non-pre-emptive split* with *pre-emptive merge* or the other 2 combinations left? Which o... |
How decide between pre-emptive split or non pre-emptive split and pre-emptive or non pre-emptive merge for a BTree? |
null |
Modern compilers are quite capable of optimizing a tuple return value so that the result is passed in registers, or in an unpacked form on the stack.
In addition, even when this is not the case, worrying about the overhead is misplaced. If the tuple fits in primary cache, chances are nobody is going to notice the di... |
null |
I consider a deterministic pushdown automaton.
Given that there are some differences between definitions, here is mine:
- the syntax is given $A = (Q, \Sigma, \Gamma, \Delta, q_0, Z_0, F)$, with $q_0\in Q$ is the initial state, $Z_0\in \Gamma$ is the starting stack symbol, $F\subseteq Q$ is the set of final states,... |
Length of an $\varepsilon$-computation in complete DPDA |
|pushdown-automata| |
null |
How to decide between pre-emptive split or non pre-emptive split and pre-emptive or non pre-emptive merge for a BTree? |
null |
I attempted to create a language $L_1$ = {$<M>| L(M) = 1^*$} and prove using a reduction that $L_1$ ∌ RE and $L_1$ ∌ CoRE by showing that $HP ≤ L_1$ and $\overline{HP}$ $≤ L_1$.
But my instructor said this isn't correct. |
Prove the existence of a language L over the alphabet Σ = {1} such that L ∌ RE and L ∌ CoRE |
|formal-languages|turing-machines| |
let L be defined as $L = \{0^{2k} | k \in \mathbb{N}\} \subset \{0,1\}^*$.
> language L can be described by a nondeterministic pushdown automaton P
> such that there exists at least one input for which P accepts the
> input by falling into an infinite loop
is this statement true or false? if it's true, then... |
infinite loop in PDA |
|pushdown-automata| |
null |
It is a very straightforward question.
I know that the following holds, and I know why it holds:
$DTIME(f(n)) \subset DSPACE(f(n))$
However, is there a language $L \in DSPACE(1) \setminus DTIME(1)$? The "1" is supposed to represent a constant complexity.
It seems to me there is not such language but I don'... |
Is there a language $L$ such that $L \in DSPACE(1) \setminus DTIME(1)$? |
|complexity-theory|time-complexity|turing-machines|space-complexity| |
null |
The language $L_1$ that you suggested is in $\text{coRE}$. Indeed, given a TM $M$ over input-alphabet $\Sigma$ of size at least 2, you can check whether $M$ accepts a word that is not of the form $1^*$ by traversing on all words in $\Sigma^*$ in parallel in minlex order. Specifically, if $w_1, w_2, w_3, \ldots$ are all... |
{"Voters":[{"Id":77862,"DisplayName":"Bader Abu Radi"}],"DeleteType":1} |
Both reductions look fine and are easy to come up with. You need to ask your instructor what is wrong with your suggested reductions.
A reduction from $HP$ to $L_1$ operates as follows. Given input $\langle M, w\rangle$, the reduction outputs $\langle T\rangle$, where $T$ is a machine that rejects every input not of... |
{"Voters":[{"Id":77862,"DisplayName":"Bader Abu Radi"}]} |
{"Voters":[{"Id":77862,"DisplayName":"Bader Abu Radi"}],"DeleteType":1} |
null |
Both reductions look fine and are easy to come up with. You need to ask your instructor what is wrong with your suggested reductions.
A reduction from $HP$ to $L_1$ operates as follows. Given input $\langle M, w\rangle$, the reduction outputs $\langle T\rangle$, where $T$ is a machine that rejects every input not of... |
{"Voters":[{"Id":77862,"DisplayName":"Bader Abu Radi"}]} |
No. Consider the language
$$L = \{x \in \{0,1\}^* \mid x \text{ has even parity}\},$$
i.e.,
$$L = \{x_1 \cdots x_n \mid x_1 + x_2 + \cdots + x_n \equiv 0 \pmod 2\}.$$
This language is in $\textsf{DSPACE}(1)$ (it can be recognized by a DFA with 2 states, so you only need 1 bit of state), but it is not in $\... |
No. Consider the language
$$L = \{x \in \{0,1\}^* \mid x \text{ has even parity}\},$$
i.e.,
$$L = \{x_1 \cdots x_n \mid x_1 + x_2 + \cdots + x_n \equiv 0 \pmod 2\}.$$
This language is in $\textsf{DSPACE}(1)$ (it can be recognized by a DFA with 2 states, so you only need 1 bit of state), but it is not in $\... |
No. Consider the language
$$L = \{x \in \{0,1\}^* \mid x \text{ has even parity}\},$$
i.e.,
$$L = \{x_1 \cdots x_n \mid x_1 + x_2 + \cdots + x_n \equiv 0 \pmod 2\}.$$
This language is in $\textsf{DSPACE}(1)$ (it can be recognized by a DFA with 2 states, so you only need 1 bit of state), but it is not in $\... |
Your language is neither in RE nor in co-RE, and the reductions you have mentioned prove this. However, it is unclear to me whether your language is using only the alphabet $\{1\}$. This depends on how your coding of TMs which underlies $\langle \cdot \rangle$ works. To the extent that you have a concrete definition of... |
Suppose we've to pick $K (\le N)$ random integers in the range $[0, N - 1]$ for very large $N$ such that there is no repetition, while also deterministically minimizing the number of calls made to the $rand()$ function. How would we do it?
Assume $rand(X)$ produces a random integer in the range $[0,X - 1]$; calling ... |
null |
I consider a deterministic pushdown automaton.
Given that there are some differences between definitions, here is mine:
- the syntax is given $A = (Q, \Sigma, \Gamma, \Delta, q_0, Z_0, F)$, with $q_0\in Q$ is the initial state, $Z_0\in \Gamma$ is the starting stack symbol, $F\subseteq Q$ is the set of final states,... |
I learned the amortized analysis of Prof Demaine's 6.006 videos. The Erik's thesis was, If we reallocate memory by doubling capacity => $$1 +2+4 + 8 + 16 +..+n = \theta(2^{lgn}) = \theta(n)$$ From Amortized analysis, we can say that after an operation we get linear complexity so the overall complexity of inserting is c... |
Amortized analysis of dynamic array insertion |
|data-structures|amortized-analysis| |
For refresher, let's first remember ([Wikipedia](https://en.wikipedia.org/wiki/Conjunctive_normal_form)) that we can convert any Boolean expression into conjunctive normal form, which is defined as conjunction ("AND") of one or more disjunctions ("OR") of one or more literals, and governed by six context-free grammar r... |
For refresher, let's first remember ([Wikipedia](https://en.wikipedia.org/wiki/Conjunctive_normal_form)) that we can convert any Boolean expression into conjunctive normal form, which is defined as conjunction ("AND") of one or more disjunctions ("OR") of one or more literals, and governed by six context-free grammar r... |
For refresher, let's first remember ([Wikipedia](https://en.wikipedia.org/wiki/Conjunctive_normal_form)) that we can convert any Boolean expression into conjunctive normal form, which is defined as conjunction ("AND" $\land$) of one or more disjunctions ("OR" $\lor$) of one or more literals, and governed by six context... |
For refresher, let's first remember ([Wikipedia](https://en.wikipedia.org/wiki/Conjunctive_normal_form)) that we can convert any Boolean expression into conjunctive normal form, which is defined as conjunction ("AND" $\land$) of one or more disjunctions ("OR" $\lor$) of one or more literals, and governed by six context... |
My question is about [LeetCode "137.Single Number II"][1]:
>**137.Single Number II**
>
> Given an integer array nums where every element appears three times
> except for one, which appears exactly once. Find the single element
> and return it.
>
> You must implement a solution with a linear runtime complexity... |
Efficient way to implement a bit-wise counter that becomes 1 every (k*n)+i times |
|counting|bit-manipulation|optimal-strategy| |
null |
null |
null |
It's hard to find the exact optimal sequence of instructions to accomplish some effect. I don't know of any systematic way, other than techniques like [superoptimization](https://en.wikipedia.org/wiki/Superoptimization), which essentially do a brute-force search over all possibilities. |
null |
The reason it is not debated is because it is obvious, the reason that B-tree was invented, and subsequently B* tree is to reduce the frequency of rebalancing. Splitting and merging both involve rebalancing, therefore the more it is delayed the better. |
In the book **[A Science of Concurrent Programs][1]** Leslie Lamport describes alternative way how to look at **safety** and **liveness** properties in distributed algorithms.
> **A.5 Another Way to Look at Safety and Liveness**
This section provides a different view of safety and liveness based on viewing
behavio... |
Topological/metric space formed by behaviors of distributed system: Safety and Liveness |
|distributed-systems|automated-theorem-proving|tlaplus| |
I was referring to the textbook Artificial Intelligence: A modern approach 3rd by Stuart Russell and Peter Norvig.
It says in 3.4.1 Breadth-first search
> As for space complexity: for *any kind of graph search*, which stores every expanded
node in the *explored* set, the space complexity is always **within a facto... |
Prove the relation between "the space complexity" and "the time complexity" of "any graph search" using "the explored set" |
|algorithm-analysis|runtime-analysis|trees|search-algorithms|graph-traversal| |
I was referring to the textbook Artificial Intelligence: A modern approach 3rd by Stuart Russell and Peter Norvig.
It says in 3.4.1 Breadth-first search
> As for space complexity: for *any kind of graph search*, which stores every expanded
node in the *explored* set, the space complexity is always **within a facto... |
I was referring to the textbook Artificial Intelligence: A modern approach 3rd by Stuart Russell and Peter Norvig.
It says in 3.4.1 Breadth-first search
> ... For these reasons, complexity is expressed in terms of three quantities: **b, the branching factor** or maximum number of successors of any node; d, the dept... |
Prove the relation between "the space complexity" and "the time complexity" of "any graph search" which uses "the explored set" |
Let $G = (V, E)$ be a flow network with a source $s$ and sink $t$.
However, the constraints are a bit different:
Conservation constraint is as usual.
For each edge $e \in E$, we have that the flow $f$ maintains that $f(e) \geq c(e)$ when $c(e)$ is the capacity of $e$.
The question asks to write an algorith... |
Minimum flow in a flow network |
|algorithms|correctness-proof|network-flow| |
{"Voters":[{"Id":755,"DisplayName":"D.W."}],"SiteSpecificCloseReasonIds":[]} |
>Let $\alpha \in (0, 1),\space l \geq 2$ and $T: \mathbb{N}\rightarrow\mathbb{R}^+$ such that, <br><br>$T(n) = \begin{cases} n^l + T(\alpha n) + T((1-\alpha)n) & : n > 1 \\1 : n=1 \end{cases}$ <br><br>
Bound $T$ asymptotically tight.
So I understand that I need to split into cases, the first one is where $\alpha... |
Bound $T$ asymptotically tight | Recursive trees |
|asymptotics|runtime-analysis|recursion|lower-bounds|upper-bound| |
Let All = {L ⊆ $∑^*$}. Prove that there isn't a [**complete**][1] language in All ( the set of all languages over the alphabet $∑^*$)
**Attempt**
Let $L$ and $\overline{L}$ be in All. And let's say there is a reduction between $L$ and $\overline{L}$. So, we can say that if there is a word w in $L$ it's also in $\... |
Prove that there aren't any complete languages in {L ⊆ $∑^*$} |
|formal-languages|turing-machines|turing-completeness| |
null |
Using the [Akra-Bazzi](https://en.wikipedia.org/wiki/Akra%E2%80%93Bazzi_method) method we have that
$
\alpha^p + (1-\alpha)^p = 1
$
for $p=1$, and that:
$$
\int_2^n \frac{x^l}{x^{p+1}} \, \text{d}x =
\int_2^n x^{l-2} \, \text{d}x= \frac{x^{l-1}}{l-1} \,\bigg|_{x=2}^{n} = \Theta(n^{l-1}).
$$
Hence:
$$
T(n... |
I have a bunch of values, some that are given by an end user input and some that are calculated based on that input.
The way that the values are calculated are input by a different group of users of the software.
My goal is to give the second group of users feedback that their input can always be solved.
_Now to t... |
Guarantee the solvability of conditional, but cyclic dependencies |
|constraint-programming|answer-set-programming| |
null |
Using the [Akra-Bazzi](https://en.wikipedia.org/wiki/Akra%E2%80%93Bazzi_method) method we have that
$
\alpha^p + (1-\alpha)^p = 1
$
for $p=1$, and that:
$$
\int_1^n \frac{x^l}{x^{p+1}} \, \text{d}x =
\int_1^n x^{l-2} \, \text{d}x= \frac{x^{l-1}}{l-1} \,\bigg|_{x=1}^{n} = \Theta(n^{l-1}).
$$
Hence:
$$
T(n... |
I was referring to the textbook Artificial Intelligence: A modern approach 3rd by Stuart Russell and Peter Norvig.
It says in 3.4.1 Breadth-first search about the general "graph search"
> ... For these reasons, complexity is expressed in terms of three quantities: **b, the branching factor** or maximum number of su... |
The standard reference for the topological characterisation is [Bowen Alpern and Fred B. Schneider. Defining liveness. *Information Processing Letters*, 21(4): 181–185, October 1985](https://doi.org/10.1016/0020-0190(85)90056-0).
One notable difference to Lamport's characterisation is that Alpern & Schneider don't i... |
I was referring to the textbook Artificial Intelligence: A modern approach 3rd by Stuart Russell and Peter Norvig.
In 3.4.1 Breadth-first search, the textbook first introduces some terminology:
> ... For these reasons, complexity is expressed in terms of three quantities: **b, the branching factor** or maximum numb... |
I was referring to the textbook Artificial Intelligence: A modern approach 3rd by Stuart Russell and Peter Norvig.
In 3.4.1 Breadth-first search, the textbook first introduces some terminology:
> ... For these reasons, complexity is expressed in terms of three quantities: **b, the branching factor** or maximum numb... |
I'm new to the complexity theory.
I came across a computation involving $O\big(\frac{n}{m-n}\big)$, with both $n$ and $m$ serving as independent variables in my algorithm (assuming $m \geq n$). Since I haven't encountered the subtraction of two variables in the denominator before, I'm curious if it can be simplifie... |
Big O notation of $O(n/(m-n))$ |
|complexity-theory|asymptotics|big-o-notation| |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.