instruction stringlengths 0 29.8k ⌀ |
|---|
The type of pseudocode I’ve most commonly seen is loosely based on ALGOL, sometimes falling back to natural language or algebraic notation.
For example, compare this sample (from Wikipedia) of Algol-60:
```lang-none
BEGIN
INTEGER p, q;
y := 0; i := k := 1;
for p := 1 step 1 until n do
for q := ... |
The case with negatives is not different.
Consider $X$ numbers in the range $1$ to $11$ and add $7X$ to the target. Then you can apply the known algorithm. (I assume that this algorithm can also handle the constraint "between $2$ and $X/2$ numbers are below $7$".) |
Let $X$ be the chosen subset of inputs to which we can restrict 3-SAT such that algorithm A remains superpolynomial.
>Then no algorithm A’ that solves 3-SAT’ can run in polynomial time on average
This does not follow from your argument. At best, assuming you can determine whether input lies in $X$ in polynomial ... |
I have a homework assignment that requires me to create CFG for
> L(G) = {w | (∃i, j, k)w = a^i b^(i+j+k) c^j d^k with Σ = {a, b, c, d}
so that it can accept words like ab, aaabbbbd, abbbcd, but it should not accept abba, aabbbbbc, or abc since the number of b must be the number of a+c+d.
I need CFG of L(G)... |
null |
I have a homework assignment that requires me to create CFG $G$ for
$$L = \{a^i b^{i+j+k} c^j d^k\}$$
so that it can accept words like ab, aaabbbbd, abbbcd, but it should not accept abba, aabbbbbc, or abc since the number of b must be the number of a+c+d.
I need CFG of L(G)
- I tried using chatgpt but t... |
null |
$S\rightarrow AD$\
$A\rightarrow aAb,\varepsilon$\
$D\rightarrow bDd, C$\
$C\rightarrow bCc, \varepsilon$.
In this solution I divided the word into a prefix of $a^ib^i$ and a suffix of $b^{j+k}c^jd^k$. The latter part is generated by building $a^kCd^k$ and then replacing $C$ with $b^jc^j$. |
$S\rightarrow AD$\
$A\rightarrow aAb,\varepsilon$\
$D\rightarrow bDd, C$\
$C\rightarrow bCc, \varepsilon$.
In this solution I divided the word into a prefix of $a^ib^i$ and a suffix of $b^{j+k}c^jd^k$. The latter part is generated by building $b^kCd^k$ and then replacing $C$ with $b^jc^j$. |
Consider
$$\begin{align} T(n^3)&=T((n-1)^3)+n\\
T(1)&=1
\end{align}$$
According to the substitution method, $T(n^3)=O(n^2)$ (please if I wrong, correct me). Now, what is the answer of $T(n)$? I think $T(n)=O(1)$ but the answer of my teacher is $T(n)=O(n^\frac{2}{3})$. |
A particular recurrence relation |
|algorithms| |
null |
The problem $⊕2SAT$ is defined as a problem where we need to find the parity of the number of solutions of $2$-$CNF$ formulae and is known to be $\oplus P$ complete.
I introduce the following variant of $⊕2SAT$:
In this variant we put the restriction on the input of the $⊕2SAT$ problem the restriction is that ev... |
Complexity of this variant of $⊕2SAT$? |
|complexity-theory|2-sat| |
Find $T(n)$ from $T(n^3)$ |
Define a function $S(n) = T(n^3)$. Then $S(n) = T(n^3) = T((n-1)^3 + n = S(n-1) + n$, and $S(1) = T(1^3) = T(1) = 1$. The answer is obviously the sum of n from 1 to n, or $n(n+1) / 2$.
So $S(n) = T(n^3) = n(n+1) / 2$, and $T(n) = n^{1/3} (n+1)^{1/3} - 1$ whenever n is a cube of some integer.
Just try T(1000) = ... |
It is my understanding, based on [this](https://quantumcomputing.stackexchange.com/questions/5215/why-doesnt-deutsch-jozsa-algorithm-show-that-p-≠-bqp) question that problems solved on quantum computers with oracles don’t make any statements about BQP in relation to other complexity classes.
> The fallacy is in the ... |
Make statements about quantum complexity theory |
|quantum-computing|oracle-machines|factoring|oracles| |
Making statements about quantum complexity theory |
Recently, I’ve been interested in the console of the Source game engine, more specifically, its `alias` command, which allows one command to invoke others. It may allow recursion (i.e. running `alias freeze freeze` will cause inputting `freeze` to freeze the engine), but does not allow parameters (i.e. running "`alias ... |
Recently, I’ve been interested in the console of the Source game engine, more specifically, its `alias` command, which allows one command to invoke others. It may allow recursion (i.e. running `alias freeze freeze` will cause inputting `freeze` to freeze the engine), but does not allow parameters (i.e. running "`alias ... |
null |
This was asked once on the HoTT-cafe list. The answer is "yes" and I composed [a short video](https://youtu.be/zn8QwIjdRaw) which explains exactly how this happens.
|
null |
The type of pseudocode I’ve most commonly seen is loosely based on ALGOL, sometimes falling back to natural language or algebraic notation.
For example, compare this sample (from Wikipedia) of Algol-60:
```lang-none
BEGIN
INTEGER p, q;
y := 0; i := k := 1;
for p := 1 step 1 until n do
for q := ... |
null |
Shor's algorithm does not use an oracle. The input is a number $n$ to be factored. $U$ is not an oracle; it is a computation that is done by the algorithm (akin to a subroutine). |
This problem can be solved easily: trivially, the number of solutions is 0, so the parity is even.
Consider any other variable $b$. Then because the formula $\varphi$ must contain all clauses that contain the variable $a$, $\varphi$ must have the form
$$\varphi = (a \lor b) \land (a \lor \neg b) \land (\neg a \l... |
Quick and dirty hack
====================
Here is a simple, easy-to-implement approach that meets your requirements and might be good enough when $X \le 100$. It does not guarantee a uniform distribution.
We will randomly and independently select $X$ numbers, from some distribution. Then, we'll test whether th... |
The type of pseudocode I’ve most commonly seen is loosely based on ALGOL, sometimes falling back to natural language or algebraic notation.
For example, compare this sample (from Wikipedia) of Algol-60:
```lang-none
BEGIN
INTEGER p, q;
y := 0; i := k := 1;
for p := 1 step 1 until n do
for q := ... |
I am told that if a decision problem that is in **NP** Complete can be solved in polynomial time, then **P**=**NP**. However, would this mean that we would instantly have an algorithm to solve *any* **NP** problem. Like if someone solved the traveling salesman problem, would that mean that we would instantly have an al... |
The extent of NP-Completeness |
|algorithms|complexity-theory|np-complete| |
The problem positive $⊕2SAT$ is defined as a problem where we need to find the parity of the number of solutions of positive $2$-$CNF$ formulae and is known to be $\oplus P$ complete.
I introduce the following variant of $⊕2SAT$:
In this variant we put the restriction on the input of the positive $⊕2SAT$ problem ... |
null |
The problem $⊕2SAT$ is defined as a problem where we need to find the parity of the number of solutions of $2$-$CNF$ formulae and is known to be $\oplus P$ complete.
I introduce the following variant of $⊕2SAT$:
In this variant we put the restriction on the input of the $⊕2SAT$ problem the restriction is that ev... |
This is like a follow up question from my previous post about complexity of $positive -⊕2SAT$.
The problem positive $⊕2SAT$ is defined as a problem where we need to find the parity of the number of solutions of positive $2$-$CNF$ formulae and is known to be $\oplus P$ complete.
I introduce the following variant o... |
Complexity of this variant of $positive -⊕2SAT$? |
|complexity-theory|2-sat| |
The famous PPAD class revolves around the End-Of-The-Line problem. Basically, it states that you are given two polynomial depth circuits, $P$ and $Q$, which act as "possible previous" and "possible next" functions, each with an exponentially sized domain. And the task is to find an input that satisfies $P(Q(x)) \neq Q(... |
"Succinct circuit representation" on Turing machines? |
|turing-machines|circuits|game-theory| |
The famous PPAD class revolves around the End-Of-The-Line problem. Basically, it states that you are given two polynomial depth circuits, $P$ and $Q$, which act as "possible previous" and "possible next" functions, each with an exponentially sized domain. And the task is to find an input that satisfies $P(Q(x)) \neq Q(... |
null |
Yes and no, even if we assume P $\not=$ NP was not proven. It depends on how someone "solved" the traveling salesman problem.
------
If someone constructed a polynomial-time algorithm that solves the traveling salesman problem, we would be able to instantly specify a polynomial-time algorithm that factors integer... |
Suppose we have $n$ intervals given in the form of (startTime,EndTime). I wish to calculate maximum length of the region that is exactly union of $1<=k<=n$ intervals.
Note that there are 2 cases for which I am trying to find an algorithm individually
1. Union of selected intervals might not be a single interval
... |
How do I select a subset of k intervals which form maximum length if we take union of these k intervals? |
|dynamic-programming|greedy-algorithms|intervals| |
Suppose we have $n$ intervals given in the form of (startTime,EndTime). I wish to calculate maximum length of the region that is exactly union of $1<=k<=n$ intervals.
Note that there are 2 cases for which I am trying to find an algorithm individually
1. Union of selected intervals might not be a single interval
... |
Select a subset of k intervals which form maximum length if we take union of these k intervals |
Many problems in computer science input boolean circuits to problems.
Just as a toy example, let's define the below problem to be called $A$:
> Given a polynomial depth circuit with $N$ bits of output, C, does there exist an input $x$ such that $C(x) = 0$?
Is it correct to say that an equivalent problem, on a ... |
Representing classical circuits with quantum gates |
|circuits|quantum-computing| |
No, it's obviously not equivalent, because computation on a quantum computer is not known to be equivalent to computation on a classical computer.
Also, it's not clear what you mean by a "quantum gate" or how it is specified on the input.
Yes, depending on the notion of completeness - it may depend on under what ... |
A circuit is not represented "on" a Turing machine, rather a representation of the circuit is provided as input. It is straightforward to represent a circuit as a bit-string. For instance, you can list each gate of the circuit, and which gates' outputs are connected to which gates' inputs.
I can't make sense of th... |
I want to reversibly transcode arbitrary information, initially $n$ bits, into symbols in an alphabet with $s$ symbols, with little space loss. In my application‡ $s=45$. Thus I can e.g. transcode $n=192$ bits into $m=\lceil n/\log_2s\rceil=\lceil34.961\ldots\rceil=35$ symbols with less than $0.12\%$ space loss.
I k... |
Base transcoding with minimum storage and complexity |
|space-complexity|base-conversion| |
I would propose to do some researching in the field of **Stance Classification**. Given a target claim or argument we can classify whether a number of sentences are in favor, against or neither of that claim. So an idea is to extract the topic of those sentences classify whether they agree or disagree with it and depen... |
null |
I want to reversibly transcode arbitrary information, initially $n$ bits, into symbols in an alphabet with $s$ symbols, with little space loss. In my application‡ $s=45$. Thus I can e.g. transcode $n=192$ bits into $m=\lceil n/\log_2s\rceil=\lceil34.961\ldots\rceil=35$ symbols with less than $0.12\%$ space loss.
I k... |
I want to reversibly transcode arbitrary information, initially $n$ bits, into symbols in an alphabet with $s$ symbols, with little space loss. In my application‡ $s=45$. Thus I can e.g. transcode $n=192$ bits into $m=\lceil n/\log_2s\rceil=\lceil34.961\ldots\rceil=35$ symbols with less than $0.12\%$ space loss.
I k... |
null |
I want to reversibly transcode arbitrary information (a digital signature), initially $n$ bits, into symbols in an alphabet with $s$ symbols, with little space loss. In my application‡ $s=45$. Thus I can e.g. transcode $n=192$ bits into $m=\lceil n/\log_2s\rceil=\lceil34.961\ldots\rceil=35$ symbols with less than $0.12... |
null |
I want to reversibly transcode arbitrary information (a digital signature), initially $n$ bits, into symbols in an alphabet with $s$ symbols, with little space loss. In my application‡ $s=45$. Thus I can e.g. transcode $n=192$ bits into $m=\lceil n/\log_2s\rceil=\lceil34.961\ldots\rceil=35$ symbols with less than $0.12... |
null |
Recently, I’ve been interested in the console of the Source game engine, more specifically, its `alias` command, which allows one command to invoke others. It may allow recursion (i.e. running `alias freeze freeze` will cause inputting `freeze` to freeze the engine), but does not allow parameters (i.e. running "`alias ... |
The type of pseudocode I’ve most commonly seen is loosely based on ALGOL, sometimes falling back to natural language or algebraic notation.
For example, compare this sample (from Wikipedia) of Algol-60:
```lang-none
BEGIN
INTEGER p, q;
y := 0; i := k := 1;
for p := 1 step 1 until n do
for q := ... |
I want to reversibly transcode arbitrary information (a digital signature), initially $n$ bits, into symbols in an alphabet with $s$ symbols, with little space loss. In my application‡ $s=45$. Thus I can e.g. transcode $n=192$ bits into $m=\lceil n/\log_2s\rceil=\lceil34.961\ldots\rceil=35$ symbols with less than $0.12... |
I want to reversibly transcode arbitrary information (a digital signature), initially $n$ bits, into symbols in an alphabet with $s$ symbols, with little space loss. In my application‡ $s=45$. Thus I can e.g. transcode $n=192$ bits into $m=\lceil n/\log_2s\rceil=\lceil34.961\ldots\rceil=35$ symbols with less than $0.12... |
null |
Unfortunately, you greedy algorithm for case $1$ may not yield the wanted maximum length sometimes.
Here is an example. We are given
$$ \begin{aligned}
I_1 &= (1,6)\\
I_2 &= (3, 9)\\
I_3 &= (5, 10)\\
\end{\aligned}$$
and $k=2$. The greedy algorithm will pick $I_2$ and then $I_1$, whose union is length $8$. How... |
Unfortunately, you greedy algorithm for case $1$ may not yield the wanted maximum length sometimes.
Here is an example. We are given
$$ \begin{aligned}
I_1 &= (1,6)\\
I_2 &= (3, 9)\\
I_3 &= (5, 10)\\
\end{aligned}$$
and $k=2$. The greedy algorithm will pick $I_2$ and then $I_1$, whose union is length $8$. Howe... |
null |
I need an algorithm that can do facial recognition in a video based on a training set. For any faces detected, it should give an output as how much the face matches with the faces in the training set.<br> How can this be done ? |
Facial Recognition |
|machine-learning|artificial-intelligence| |
I want to reversibly transcode arbitrary information (a digital signature), initially $n$ bits, into symbols in an alphabet with $s$ symbols, with little space loss. In my application‡ $s=45$. Thus I can e.g. transcode $n=192$ bits into $m=\lceil n/\log_2s\rceil=\lceil34.961\ldots\rceil=35$ symbols with less than $0.12... |
I am trying to solve the Longest Increasing Subsequence(LIS) Problem using different OPT Function than the one which normally used. I have been given this question as an extra credit and I have been trying to wrap my head around the different OPT Functions and the recurrence relation possible. The solutions I found alw... |
Recurrence Relation for Longest Increasing Subsequence Problem |
|dynamic-programming|recurrence-relation|longest-increasing-subsequence| |
Divide the first 187 bits into 17 blocks of 11-bit values. This leaves 5 bits left over. Call each 11-bit block *good* if it it corresponds to a number in the range $0 \ldots 2024$, or *bad* if it is in the range $2025 \ldots 2047$. (Note that $2025 = 45^2$, so a good block can be encoded into two symbols.) We'll s... |
Divide the first 187 bits into 17 blocks of 11-bit values. This leaves 5 bits left over. Call each 11-bit block *good* if it it corresponds to a number in the range $0 \ldots 2024$, or *bad* if it is in the range $2025 \ldots 2047$. (Note that $2025 = 45^2$, so a good block can be encoded into two symbols.) We'll s... |
I want to reversibly transcode arbitrary information (a digital signature), initially $n$ bits, into symbols in an alphabet with $s$ symbols, with little space loss. In my application‡ $s=45$. Thus I can e.g. transcode $n=192$ bits into $m=\lceil n/\log_2s\rceil=\lceil34.961\ldots\rceil=35$ symbols with less than $0.12... |
I want to reversibly transcode arbitrary information (a digital signature), initially $n$ bits, into symbols in an alphabet with $s$ symbols, with little space loss. In my application‡ $s=45$. Thus I can e.g. transcode $n=192$ bits into $m=\lceil n/\log_2s\rceil=\lceil34.961\ldots\rceil=35$ symbols with less than $0.12... |
I want to reversibly transcode arbitrary information (a digital signature), initially $n$ bits, into symbols in an alphabet with $s$ symbols, with little space loss. In my application‡ $s=45$. Thus I can e.g. transcode $n=192$ bits into $m=\lceil n/\log_2s\rceil=\lceil34.961\ldots\rceil=35$ symbols with less than $0.12... |
null |
I know the basics about base64 encoding, but thinking about it abstractly I have a theoretical question.
If we consider base64 a mathematical function(in our case computable), Does there exists an invariant for base64-encoding function ? It only make sense or to narrow down the scope of the question I assume input b... |
ASCII invariant string for base64 Encoding |
|computability|strings|binary|encoding-scheme| |
null |
No, it is impossible. The base64 encoding of any string is always longer than the string itself. |
null |
null |
I am currently learning about NP and coNP related content and have been exposed to the$NP \overset{\text{?}}{=}coNP$ problem.
I would like to know what are the directions to work on if I want to prove that $NP=coNP$? For example, currently I know that if I can prove that a coNP-complete language belongs to NP, then ... |
I would like to know what are the directions to work on if I want to prove that $NP=coNP$? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.