instruction
stringlengths
0
29.8k
⌀
I am trying to calculate the number of iterations of a sequence of nested loops of the form: \begin{equation} N = \sum_{j=0}^{j_T} \sum_{k=0}^{j} \sum_{l=0}^{k} \sum_{n=n_0}^{n_T} 1 \end{equation} where $j_T\ge 0$ and $n_T\ge 0$ are known constants. For $n_0 = 0$ the case is trivial and can be calculated usi...
I'm trying to use the Pumping Lemma to prove that $L = \{ wsw | w ∈ \{0,1\}^*,\ s ∈ {2}^*\ and |w| = 2\cdot|s| \}$ is not a CFL.
null
I'm trying to use the Pumping Lemma to prove that $L = \{ wsw \mid w \in \{0,1\}^*,\ s \in \{2\}^*\text{ and } |w| = 2\cdot|s| \}$ is not a CFL.
How to use Pumping Lemma $L = \{ wsw \mid w \in \{0,1\}^*, s \in \{2\}^* \text{, and } |w| = 2 \cdot |s| \}$?
Studying Os development I encountered the need to interface with the Hard Disk Drive and thus i started learning how it actually works. One of the problems that i found studying was that different sources said and claimed different things about the Hard Drive's structure. So, i have some questions: 1. Is a Sector a ...
Confusion with Hard Disk structure
|storage|
Here is a (in my opinion) simpler argument than John L.'s and the one the book suggests with its hint. Note that (if the array has more than 1 element) the main loop of QuickShuffle partitions the array in two, $A[1..k]$ and $A[k+1..n]$, and each element in $A$ has a 50% chance of ending up in either partition. Then...
Consider I have the following binary image (each pixel is either 0 or 255). How to count the number of lines (they could be straight or a little curvy). For example, in this picture, there are six lines except for the circle. [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/KGZpp.png
Count the number of lines in binary image
|computer-vision|image-processing|
Here is a (in my opinion) simpler argument than John L.'s and the one the book suggests with its hint. Note that (if the array has more than 1 element) the main loop of QuickShuffle partitions the array in two, $A[1..k]$ and $A[k+1..n]$, and each element in $A$ has a 50% chance of ending up in either partition. Then...
I'm not an expert but here is how I understand it. 1. A sector describes a radial slice of each platter, i.e., it contains a portion of each track. The term is somewhat ambiguous as it is often used to refer to a particular portion of a given track. Wikipedia calls the former a "geometrical sector" and the latter a "...
null
Turing complete means no size limits. For the C language, it’s easy to define an implementation with language-based limits that are way beyond physical limits. So you will never have an actual machine running into the limits. But the limits are there, so C is not Turing complete. But if the limits are so high t...
Turing complete means no size limits. For the C language, it’s easy to define an implementation with language-based limits that are way beyond physical limits. So you will never have an actual machine running into the limits. But the limits are there, so C is not Turing complete. But if the limits are so high t...
I'm not an expert but here is how I understand it. 1. A sector describes a radial slice of each platter, i.e., it contains a portion of each track. The term is somewhat ambiguous as it is often used to refer to a particular portion of a given track. Wikipedia calls the former a "geometrical sector" and the latter a "...
First, no this would not mean $P=NP$. That is a concept framed in the context of Turing machines. While it's been shown that UMMs are as expressive as Turing machines, it's not clear whether a physical realization of them would be Turing equivalent or simply *more* expressive than a Turing machine. If equivalence were ...
null
One approach is to use the [Hough transform](https://en.wikipedia.org/wiki/Hough_transform) to find lines. Skeletonization might also be of interest to you.
Given $n\times n$ dense real valued matrices $A_1,\ldots, A_L$ let $P_i=A_1\ldots A_i$ For each $P_i$ I'm interested in obtaining the sum of all rows, and the sum of all columns. Naive approach: - takes $O(L)$ time to get $L$ rows sums - takes $O(L^2)$ time to get $L$ column sums **Is there a way to estimate...
Estimating column sums of $A_1,\ A_1 A_2,\ A_1A_2A_3,\ \ldots$
|dynamic-programming|approximation|linear-algebra|
Given $n\times n$ dense real valued matrices $A_1,\ldots, A_L$ let $P_i=A_1\ldots A_i$ For each $P_i$ I'm interested in obtaining the sum of all rows, and the sum of all columns. Naive approach: - takes $O(L n^2)$ time to get $L$ rows sums - takes $O(L^2 n^2)$ time to get $L$ column sums **Is there a way to ...
Given $n\times n$ dense real valued matrices $A_1,\ldots, A_L$ let $P_i=A_1\ldots A_i$ For each $P_i$ I'm interested in obtaining the sum of all rows, and the sum of all columns. Naive approach: - takes $O(L n^2)$ time to get $L$ rows sums - takes $O(L^2 n^2)$ time to get $L$ column sums **Is there a way to ...
This answer is on the **dynamic programming** algorithm to solve the problem. I think it's better to present it as a new answer, instead of attaching it to my previous answer about the backtracking algorithm. Define a *distinct* factorization as the factorization of distinct factors. Let the *order* of a factoriz...
null
Here's a sketch of a PDA which does the job: In state $q_0$, push the symbol `|` (a tally marker) onto the stack and consume one input symbol, or do an epsilon transition to $q_1$. In state $q_1$, on input $1$, pop a tally marker and transition to $q_2$. On input $0$, pop a tally marker and stay in $q_1$. In s...
According to [this answer][1], this problem is not computable by a deterministic Turing machine in number of steps polynomial in the input size (though it is polynomial time computable under the Arithmetic model). Does this imply that the decision version of the problem is not in $P$? [1]: https://cs.stackexchan...
Is complexity of computing $2^n$ in P?
|complexity-theory|time-complexity|turing-machines|
According to [this answer][1], given input $2^n$ (and thus input size $n$), this problem is not computable by a deterministic Turing machine in number of steps polynomial in the input size (though it is polynomial time computable under the Arithmetic model). Does this imply that the decision version of the problem is n...
Is complexity of computing $2^{2^n}$ in P?
You did not specify what is the decision version of the problem you are interested in. I assume that it is the following: Input: A pair $\langle x, k \rangle$ Where: - $x$ is an integer of the form $2^n$ for some non-negative integer $n$ (encoded in base $2$). - $k$ is a positive integer. Notice that the input...
Lookaround assertions do not extend expressive power of regular expressions: it is still the set of regular languages. See [this paper][1] for proof. There is also a reference to the paper where they prove this by conversion to a DFA. [1]: https://doi.org/10.3897/jucs.66330
null
null
null
I've been tasked with solving this problem, but I'm not sure where to begin: > Let $L$ be a context-free language. $L'$ contains all the words that belong to $L$ which can't be defined as $z=uvwxy$, for which $|vx|>0$ so that $\forall i \ge0$ we get $uv^iwx^iy\in L$. > > Is $L'$ a regular language, context free b...
Prove a subset of a regular language is regular, context-free but not regular or not context free
|formal-languages|regular-languages|automata|context-free|formal-grammars|
Since $L$ is a context-free language, [there must be][1] some integer $p$ such that any word $z \in L$ such that $|z| \ge p$ can be written as $z = uvwxy$ with $|vx|>0$ and $uv^iwx^iy \in L$ for all $i \ge 0$. This means that no word $z$ with $|z| \ge p$ can be in $L'$, i.e., all words in $L'$ have length at most $p...
Since $L$ is a context-free language, [there must be][1] some integer $p \ge 1$ such that any word $z \in L$ such that $|z| \ge p$ can be written as $z = uvwxy$ with $|vx|>0$ and $uv^iwx^iy \in L$ for all $i \ge 0$. This means that no word $z$ with $|z| \ge p$ can be in $L'$ and hence $|L'| \le \sum_{i=0}^{p-1} |\Si...
I have just started to study "Lambda-Calculus and Combinators, an Introduction" by Roger Hindley. There is a formulation of B ̈ohm’s theorem that I can not understand. [![enter image description here][1]][1] $M$ and $N$ are terms in bn-normal form. Based on the description I assume that $M$ could be equal to λ...
What are distinguishable terms in B ̈ohm theorem?
|lambda-calculus|
null
null
My question relates to Problem 22.-2 in Introduction to Algorithms 3rd edition. There biconnected components are defined as maximal sets of edges such that any two edges in the set lie on a common simple cycle. The problems that I am having are the last two tasks of this problem, namely 1. proving that biconnecte...
Computing biconnected components
|graphs|
null
It seems that a simulating halt decider H can be applied to the halting problem's "impossible" input template P such H correctly predicts that is input would never terminate normally. I have re-written this explanation thousands of times and it is finally simple enough to be understood. #define ptr uintptr_t ...
It seems that a simulating halt decider H can be applied to the halting problem's "impossible" input template P such H correctly predicts that is input would never terminate normally. I have re-written this explanation thousands of times and it is finally simple enough to be understood. #define ptr uintptr_t ...
A simple graph with n vertices is connected if it has more than (n−1)(n−2)/2 edges. The n vertex graph with the maximal number of edges that is still disconnected is a Kn−1 a complete graph Kn−1 with n−1 vertices has (n−1)/2edges, so (n−1)(n−2)/2 edges. Adding any possible edge must connect the graph, so the...
We have property $$O(f)+O(f)=O(f)$$ which means, that you can add big-$O$ fixed amount times and still get same. It's like your program have several consecutive parts with one and same complexity. Then all program have that complexity. As to second question, then you can try to prove following $$ O(n^{k}) + O(n^...
null
null
We have property $$O(f)+O(f)=O(f)$$ which means, that you can add big-$O$ fixed amount times and still get same. It's like your program have several consecutive parts with one and same complexity. Then all program have that complexity. As to second question, then you can try to prove following $$ O(n^{k}) + O(n^...
null
A strict left fold is straightforward to implement as a loop, rather than with recursion: ``` foldl(fn, acc, list) loop until empty(list) acc ← fn(acc, head(list)) list ← tail(list) return acc ``` For a strict right fold, the best I've been able to come up with is by maintaining a ...
Can a strict right fold be implemented in a single loop?
|recursion|functional-programming|loops|
null
**Halting problem proofs refuted on the basis of software engineering** This is an explanation of a key new insight into the halting problem provided in the language of software engineering. Technical computer science terms are explained using software engineering terms. No knowledge of the halting problem is requi...
Constructivist mathematics states that in order to prove something, we must construct this something, in a notion similar to computation, where things don't spring out of nowhere from some "mystery platonic relationship". The theory behind this I already know. A thing that I just can't understand is, if computation req...
If computers only work with intuitionistic/constructivist logic, so how it works with binary code?
|computability|logic|
Consider I have the following binary image (each pixel is either 0 or 255). How to count the number of lines (they could be straight or a little curvy). For example, in the picture, there are six lines except for the circle. The goal is to compute the number of cracks and its total areas. [![enter image description ...
In the standard definition of the Index problem in one-way 2-party communication complexity, there are two players, Alice and Bob. Alice gets a binary input vector $x$ of length $n$ and Bob gets an index $i$. Alice can send a single message to Bob who must output $x_i$. It is known that this problem has a lower bound o...
Communication complexity of index problem with large domains
|randomized-algorithms|communication-complexity|
I was reading this classical Coin Problem ([7.1][1]): Given a set of coin values coins = {c1, c2,..., ck} and a target sum of money n, our task is to form the sum n using as few coins as possible. I fully understood the discussion until I encountered the last code snippet of the section [*Constructing A Solution*]...
Unable to understand how the lwhile loop extracts exaclty what is needed
|data-structures|dynamic-programming|arrays|coin-change|
The complexity is expressed by the *iterated logarithm* function. There is no better expression.
The complexity in terms of the number of logarithm evaluations is expressed by the *iterated logarithm* function. There is no better expression. Note the following values: $$[0,1]\to0\\(1,2]\to1\\(2,4]\to2\\(4,16]\to3\\(16,65536]\to4\\(16,2.003529930406\cdots\times10^{19728}]\to5\\\cdots$$
Optimal path problem with constraint of minimal weight
Given an undirected weighted graph $G$ and two vertices $s, t$. We want to find a path $P$ from $s$ to $t$ that minimizes the following objective function $L$ $$L(P) = max(len(P), max\{c(e) \mid e \in P\})$$ For example, consider the following graph [![enter image description here][1]][1] Here we have two w...
null
What are distinguishable terms in Bohm theorem?
null
I am currently studying triangular mesh generation in 2D and, in that connection, the Delaunay triangulation of a list of vertices $\{ v_1, v_2, ..., v_N \}$. The divide and conquer algorithm of Lee & Schachter (from their paper "Two Algorithms for Constructing a Delaunay Triangulation", 1980) constructs the Delaunay t...
Computing the unique triangles and edges from vertex connectivity of a Delaunay triangulation
|computational-geometry|triangulation|
Determine the time complexity of this algorithm (pseudocode)
I believe I have come up with a solution, but I'm not convinced. We observe that, from `foldr(fn, acc, list)`, we can rewrite the intermediary steps as a series of single-valued functions: $$ eval_0 : x \mapsto fn(list_0,x) \\ eval_1 : x \mapsto eval_0(fn(list_1, x)) \\ \vdots \\ eval_n : x \mapsto eval_{n-1}(fn...
I believe I have come up with a solution, but I'm not convinced. We observe that, from `foldr(fn, acc, list)`, we can rewrite the intermediary steps as a series of single-valued functions: $$ eval_0 : x \mapsto fn(list_0,x) \\ eval_1 : x \mapsto eval_0(fn(list_1, x)) \\ \vdots \\ eval_n : x \mapsto eval_{n-1}(fn...
Unable to understand how the while loop extracts exactly what is needed
|algorithms|recursion|functional-programming|loops|
<!-- The name *first* does not implies that you have to select coin `first[n]` when you try to form a sum of `n`. A simpler and equivalent understanding of `first[n]` is, in order to form a sum of `n` using the least number of coins, you can include coin `first[n]`. In this sense, I would name the array `first` by `c...
null
<!-- The name *first* does not implies that you have to select coin `first[n]` when you try to form a sum of `n`. A simpler and equivalent understanding of `first[n]` is, in order to form a sum of `n` using the least number of coins, you can include coin `first[n]`. In this sense, I would name the array `first` by `c...
I was reading this classical Coin Problem ([7.1][1]): Given a set of coin values coins = {c1, c2,..., ck} and a target sum of money n, our task is to form the sum n using as few coins as possible. I fully understood the discussion until I encountered the last code snippet of the section [*Constructing A Solution*]...
Unable to understand how the while loop extracts the least number of coins with given sum
A strict left fold is straightforward to implement as a loop, rather than with recursion: ``` foldl(fn, acc, list) loop until empty(list) acc ← fn(acc, head(list)) list ← tail(list) return acc ``` For a strict right fold, the best I've been able to come up with is by maintaining a ...
null
In a classical definition of the **FPT** complexity class, for a parametrized problem $L\subseteq \Sigma^* \times \mathbb{N}$ we require an algorithm, solving an instance $(G,k)$ in time $f(k)\cdot n^{O(1)}$, where *$f$ is a computable function*. Very simillarly, there is a notion of *parametrized reduction*, where ...
Why do we care about computable functions in parametrized complexity definitions?