instruction stringlengths 0 29.8k ⌀ |
|---|
null |
Let $S(n) := T(2^n)$, then $S(0) = 1$ and $S(n) = S(n-1) + n^2$ for $n ≥ 1$. $S(n)$ is therefore just a straightforward sum, $1 + sum(n'^2)$ for $1 ≤ n' ≤ n$, roughly $n^3 / 3$.
So $T(n)$ = roughly $(\log n)^3 / 3$ if n is a power of two, you can find the exact value. If n is not a power of two then $T(n^k) ≤ T(n) ... |
Let $S(n) := T(2^n)$, then $S(0) = 1$ and $S(n) = S(n-1) + n^2$ for $n ≥ 1$. $S(n)$ is therefore just a straightforward sum, $1 + sum(n'^2)$ for $1 ≤ n' ≤ n$, roughly $n^3 / 3$.
So $T(n)$ = roughly $(\log n)^3 / 3$ if n is a power of two, you can find the exact value. If n is not a power of two then $T(n^k) ≤ T(n) ... |
**Executable:** Sat *prog* <br/>
**Definition:** The exit status of "Sat *prog*" is 1 iff there exists an instance <br/>
*prog arg* which runs in P-time and the exit status is 1. <br/>
<br/>
From the definition, Sat computes a ℕℙ problem. <br/>
If ℕℙ=ℙ, then, an executable f exists that "Sat f" should run in P-t... |
null |
I am reading the book "Automata, Formal Languages, and Automata" written by Dr. Emre Sermutlu and in page 153, it is stated that the following grammars are not in Chomsky Normal Definition (CNF):
> $G_1$ : <br> $S\rightarrow TT\mid a$ <br> $T\rightarrow ST \mid b$ <br>
>
> $G_2$ : <br> $S \rightarrow TT \mid a$ <... |
null |
null |
null |
**Executable:** Sat *prog* <br/>
**Definition:** The exit status of "Sat *prog*" is 1 iff there exists an instance <br/>
*prog arg* which runs in P-time and the exit status is 1. <br/>
<br/>
From the definition, Sat computes a ℕℙ problem. <br/>
If ℕℙ=ℙ, then, an executable f exists that "Sat f" should run in P-t... |
Given A a countable set and min the function returning the minimum of a set (if exists).
Is min(A) computable? My first try is thinking A as infinite list A=[a_0, a_1, a_2,...] such that a_i < a_j for every i < j and write a simple while program P such that P(A) = a_0. Is that correct? If so I wonder who is the equiva... |
Be A a countable set. Is min(A) function computable? |
|computability| |
null |
{"Voters":[{"Id":39,"DisplayName":"Gilles 'SO- stop being evil'"},{"Id":16034,"DisplayName":"Yves Daoust"},{"Id":79440,"DisplayName":"Nathaniel"}]} |
Your question lacks some details and without additionnal precisions, the answer is no.
For $n\in \mathbb{N}$, denote $S(n)$ the maximum number of steps that a Turing machine with $n$ states that take before halting with an empty input, on the alphabet $\Sigma = \{0, 1\}$. It is a well known fact that [$S(n)$ is not ... |
I try to wrap my head around the Floyd-Warshall algorithm, and I don't understand why the shortest path is guaranteed to be found since we check only the alternative connections up to one hop deep.
For example, let's consider the following graph with four vertices:
A B C D
A 0 5 -1 x
... |
Intuition of Flod-Warshall shortest path algorithm |
|graphs|shortest-path| |
(Kleene-Roy-)Floyd-Warshall(-Ingerman)'s algorithm is defined iteratively, progressively increasing the number of allowed intermediate vertices.
1. at the first step, no vertex is allowed as an intermediate. Since $(A, B)$ is an edge, $w(A, B) = 5$ is considered the minimum possible weight. Overall, the matrix of d... |
How can we design a data structure (storing ordered data) that gives the best lookup complexity possible, under the constraint that we require the insertion complexity to be at most $\mathcal O(\log\log n)$? (For clarity, I am considering equality `==` and inequality `<` tests to be the only "costly" operations and con... |
Optimal lookup complexity when requiring insertion complexity to be at most $\mathcal O(\log\log n)$? |
|complexity-theory|time-complexity|data-structures|asymptotics| |
How can we design a data structure (storing ordered data) that gives the best worst-case lookup complexity possible, under the constraint that we require the worst-case insertion complexity to be at most $\mathcal O(\log\log n)$? (For clarity, I am considering equality `==` and inequality `<` tests to be the only "cost... |
null |
null |
This problem can be regarded as a scheduling problem.
Each interval corresponds to a job. For each interval $[L_i,R_i]$, Let $r_i = L_i$ be the release time, $d_i = R_i + 2$ be the deadline, and $p_i = 2$ be the job length. Then, single-machine no-preemption scheduling corresponds to a solution. Scheduling with non-... |
To make the question better defined, we must specify the initial countable set $A$ of natural numbers, so that the specification can be used as input for our computer. Thus we assume that there is a program $E$ that lists the elements of $A$ one by one, not necessarily in order. Thus $A$ is *recursively enumerable*.
... |
null |
I am currently reading nearest Neighbour search problem where given a set of points, preprocess it so that given a query point one can find a nearest neighbor.
There are two phases, preprocessing phase and query phase.
I am trying to design a parallel algorithm for nearest neighbor search problem, but I am confuse... |
How to show that Nearest Neighbour be parallelable? |
|nearest-neighbour| |
L1, L2, and L are not finite. We're given that L and L2 are regular. However, L1 ∩ L2 is empty, since L2 is the complement of L1. Is L2 regular under the property that regular languages are closed under union? I have been going back and forth about this for a while and any help would be appreciated. Thank you! |
If L = L1 U L2 is regular, L2 is the complement of L1 (which means L1 ∩ L2 = Ø), and we're given that L and L2 are regular, is L1 regular? |
|complexity-theory|regular-languages|finite-automata|regular-expressions| |
L1, L2, and L are not finite. We're given that L and L2 are regular. However, L1 ∩ L2 is empty, since L2 is the complement of L1.
Is L1 regular under the property that regular languages are closed under union? I have been going back and forth about this for a while and any help would be appreciated. Thank you! |
If $L_1$ is the complement of $L_2$ and $L_2$ is regular then $L_1$ must be regular since regular languages are [closed](https://en.wikipedia.org/wiki/Regular_language#Closure_properties) under complement. |
If $L_1$ is the complement of $L_2$ and $L_2$ is regular then $L_1$ must be regular since regular languages are [closed](https://en.wikipedia.org/wiki/Regular_language#Closure_properties) under complement.
But if you are asking if we can infer that $L_1$ is regular given only that $L_2$ and $L$ are regular without ... |
If $L_1$ is the complement of $L_2$ and $L_2$ is regular then $L_1$ must be regular since regular languages are [closed](https://en.wikipedia.org/wiki/Regular_language#Closure_properties) under complement. Furthermore, since $L_1$ and $L_2$ are complements and $L = L_1 \cup L_2$, then $L_1 = L - L_2$ and regular langua... |
If $L_1$ is the complement of $L_2$ and $L_2$ is regular then $L_1$ must be regular since regular languages are [closed](https://en.wikipedia.org/wiki/Regular_language#Closure_properties) under complement. Furthermore, since $L_1$ and $L_2$ are complements and $L = L_1 \cup L_2$, then $L_1 = L - L_2$ and regular langua... |
null |
Given a sparse undirected graph G(V,E) where E=O(|V|), a one-hop path between a pair of vertices (u,v) is a path in G connecting (u,v) where there is exactly one intermediate vertex between the vertices i.e. u <-> t <-> v where t is the intermediate vertex, (u,t,v) are distinct vertices.
(actually I am not entire s... |
Counting number of 1-hop paths in a sparse graph |
|graphs|combinatorics| |
The language L1 is L \ L2. Take the FSMs for L and L2, create a new state machine whose states are pairs of states of these two FSMs, transitioning accordingly, and the accepting states are those that accept L but not L2.
Basically the same prove as for union or intersection or complement. |
How would someone create a Turing machine that computes ceil(sqrt(n))?
n = 1, 2, 3, 4, 5, 6, 7, 8, 9, ...
f(n) = 1, 2, 2, 2, 3, 3, 3, 3, 3 ....
And that I want the input tape to have n 1's in it to represent the number
i.e. 5 would be #11111
How would the turning machine with transition table for this be creat... |
Turing machine for square root of 2 - transition table |
|turing-machines|automata| |
Turing machine for square root of n - transition table |
How would someone create a Turing machine that computes ceil(sqrt(n))?
n = 1, 2, 3, 4, 5, 6, 7, 8, 9, ...
=> f(n) = 1, 2, 2, 2, 3, 3, 3, 3, 3 ....
And that I want the input tape to have n 1's in it to represent the number
i.e. 5 would be #11111
How would the turning machine with transition table for this be cr... |
null |
I'm struggling in finding a correct way to approach this, I'm aware that this problem is solveable using dynamic programming, and this problem somehow relates to the "max non-contiguous subarray" problem, yet I cant make the connection.
Given an array of integers, $A=\{a_1,\ldots , a_n\}$ for which $\sum_{i=1}^{n}a_... |
Minimal number of positive intervals |
|dynamic-programming|maximum-subarray| |
Given a sparse undirected graph $G=(V,E)$ where $|E|=O(|V|)$, a one-hop path between a pair of vertices $(u,v)$ is a path in $G$ connecting $(u,v)$ where there is exactly one intermediate vertex between the vertices i.e. $u \leftrightarrow t \leftrightarrow v$ where $t$ is the intermediate vertex, $(u,t,v)$ are distinc... |
null |
I'm struggling in finding a correct way to approach this, I'm aware that this problem is solveable using dynamic programming, and this problem somehow relates to the "max non-contiguous subarray" problem, yet I cant make the connection.
Given an array of integers, $A=\{a_1,\ldots , a_n\}$ for which $\sum_{i=1}^{n}a_... |
Is it possible to generalize the O(log(n)) method for point in polytope in 2d dimensions for arbitrary dimensions? If so, what would be the method? I tried to do so myself but the lack of cross product in arbitrary dimension made it seem hard. |
Point in polytope in arbitrary dimension |
|complexity-theory|computational-geometry|polygons| |
I think this is possible in $\mathcal{O}(|V|\sqrt{|V|})$ for all $Q$ queries.
Assume the graph is represented as an array of adjacency sets: for $v\in V$, $G[v]$ is a set containing all neighbors of $v$.
Then the number of $1$-hops from $u$ to $v$ is the size of $G[v]\cap G[u]$. This can be computed in $\mathcal{... |
I think this is possible in $\mathcal{O}(|V|\sqrt{|V|})$ for all $Q$ queries.
Assume the graph is represented as an array of adjacency sets: for $v\in V$, $G[v]$ is a set containing all neighbors of $v$.
Then the number of $1$-hops from $u$ to $v$ is the size of $G[v]\cap G[u]$. This can be computed in $\mathcal{... |
null |
I'm struggling in finding a correct way to approach this, I'm aware that this problem is solveable using dynamic programming, and this problem somehow relates to the "max non-contiguous subarray" problem, yet I cant make the connection.
Given an array of integers, $A=\{a_1,\ldots , a_n\}$ for which $\sum_{i=1}^{n}a_... |
Try all squares increasingly until you exceed the input. For this, consider a process that erases the first digit, then the next three, the next five, the next seven and so on, while lengthening a sequence of ones. When the input is exhausted, you are done. |
null |
You are facing a special type of analysis, called *amortized*. This is necessary when the running time of an operation can vary widely from one execution to the next, for instance due to periodic reorganization.
The main purpose of the study is to establish an $O(n)$ bound ("at most") for the insertion of $n$ elemen... |
You are facing a special type of analysis, called *amortized*. This is necessary when the running time of an operation can vary widely from one execution to the next, for instance due to periodic reorganization.
The main purpose of the study is to establish an $O(n)$ bound ("at most") for the insertion of $n$ elemen... |
How do I show the correctness proof of Dijkstra’s algorithm for negative edge weight
$\textbf{indicating the point in the proof where it breaks or does not hold}?$
I tried proving it like this, but i know that i'm not correct.
1. Set $d[s] = 0$ (where $s$ is our source).
2. Set $d[v] = \infty$ for all $v \ne ... |
Proof showing when Dijkstra’s algorithm fails for negative edge weights |
|algorithms|graphs|dijkstras-algorithm| |
This problem can be split into two steps.
1. For each index $\ell$ with $a_\ell>0$, find the largest index $r$ such that $\sum_{k=l}^ra_k>0$.
2. Cover all positive elements with minimum number of intervals of the form $(l,r)$.
### Compute all $(l,r)$'s
1. Compute the prefix sum array $s$, $s_i=\sum_{k=1}^ia_i$ ... |
I'm struggling in finding a correct way to approach this, I'm aware that this problem is solvable using dynamic programming, and this problem somehow relates to the "max non-contiguous subarray" problem, yet I cannot make the connection.
Given an array of integers, $A=\{a_1,\ldots , a_n\}$ for which $\sum_{i=1}^{n}a... |
|algorithms|dynamic-programming|greedy-algorithms|maximum-subarray| |
null |
Given a permutation on the array of integers 1 through n, I want to find the index of the permutation in a list of all possible permutations of those integers, sorted in lexicographic order.
For example, given the permutation `{1, 3, 2}` with n=3, I want the program to return `1`, because
the array has 6 permutatio... |
Compute Permutation Number |
|optimization|permutations|c++| |
A first observation is that for all $k\in \{1, …, n\}$, there are $(n-1)!$ permutations of size $n$ beginning with $k$.
For a permutation $\sigma = (k_1, …, k_n)$, that means that the rank of $\sigma$ is at least $(k_1-1)\times (n-1)!$.
What you can do to find the exact rank is updating $(k_2, …, k_n)$ by replac... |
null |
Consider the following schedule:
```python
for k = 1, 2, 3, 4...:
T_k = 2^k
for all programs p ordered by increasing length:
if floor(T_k 2^{-l(p)}) > 0: # equiv to: if l(p) ≤ k
run p for T_k 2^{-l(p)} steps # = 2^{k-l(p)}
if p has halted (on its own) and the output string matches the targe... |
The proof is correct (modulo the typo I mentionned in the comment).
Why is that not a problem about Dijkstra's correctness for negative weights? Because what you proved is $d[f] \geqslant SP(s, f)$, not $d[f] = SP(s, f)$.
It is the inequality $SP(s, f)\geqslant d[f]$ at the end of the algorithm that fails with ne... |
null |
|algorithms|computational-geometry|polygons| |
This task is known as ranking permutations. It can be solved with the factorial number system (https://en.wikipedia.org/wiki/Factorial_number_system). See also https://stackoverflow.com/q/1506078/781723, https://stackoverflow.com/q/39839119/781723 for further explanations.
More generally, see ranking and unranking... |
Given a set of points, and a convex d-dimensional polytope represented only by a set of its' vertices, I need to query in order to check for each point if it's inside the polytope. I know of the O(log(n)) solution in 2D (like the answer to https://stackoverflow.com/questions/36135978/show-that-given-a-query-point-q-it-... |
Points in convex d-dimensional polytope |
null |
Merge sort and FFT are both divide and conquer algorithms that split the input in two repeatedly. While merge sort can be applied to any $n$, the FFT algorithm given in CLRS (section 30.2, third edition) only applies when $n$ is a power of $2$. How come we can forge ahead with any $n$ for merge sort, but not quite for ... |
Why does merge sort work for any $n$, but the basic FFT algorithm only for powers of $2$? |
|divide-and-conquer|mergesort|fast-fourier-transform| |
null |
null |
null |
If javascript's object is just associative array, what makes it non-primitive as they have labeled it? It is certainly already built in. Its not like I'm creating my own concrete implementation of associative array before i begin coding on it.
According to wiki's quote:
> **Primitive data types** or built-in ... |
Why is Javacript's Object not a primitive data type? |
|data-structures|programming-languages| |
From tutorials point:
> Subtract micro-operation are using minus operator we create 1's complement and add 1 to the register which obtains subtracted, i.e R1 - R2 is similar to R3 → R1 + R2' + 1
$$
R2'= 0011
$$
$$
R3=R1+R2'+1
\\\Rightarrow R3 = 1011+0011+1
\\\Rightarrow R3 = 1111
$$
This is obvious... |
Perform subtraction micro operation R3←R1-R2 where R1=1011 and R2=1100 |
|computer-architecture| |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.