instruction
stringlengths
0
29.8k
⌀
|algorithms|lower-bounds|
null
null
I think the prime reason why **register** machines are better at performance because **registers** are within the **CPU** chip itself, however stack is generally the part of main memory, accessing register is on average **1-3** clock cycles, **level 1 cache** requires nearly **10-20 cycles** on average, and depending o...
Your idea to use a trie is good. I think that what might do the trick is only to store additionnal information at each node: the number of strings of $A$ and of $B$ contained in the corresponding subtree. This does not change the time complexity of usual operations on tries, you only need to adjust the numbers in th...
I read [this link][1] and I have similar question. Suppose given two Arrays $A$ that is sorted array with length $n$ and $B$ unsorted array with length $n$. We want to find union of two arrays (i.e. we try to compute $A\cup B$) with comparison computation model. Can we claim that the lower bound of this problem is $...
Lower bound union of a unsorted array with sorted array
|algorithms|lower-bounds|
I think this is possible in $\mathcal{O}(n)$ average case, using [hashtables](https://en.wikipedia.org/wiki/Hash_table). You just need to create a hashtable of your elements, and before adding a new one to the result, you can check in $\mathcal{O}(1)$ average if it is already present, and add it to the hashtable if ...
I think this is possible in $\mathcal{O}(n)$ average case, using [hashtables](https://en.wikipedia.org/wiki/Hash_table). You just need to create a hashtable of your elements, and before adding a new one to the result, you can check in $\mathcal{O}(1)$ average if it is already present, and add it to the hashtable if ...
Consider the following proof from Papadimitriou's "On the Complexity of Integer Programming": [![enter image description here][1]][1] It is not clear to me how $|S_J| \le (nB)^m$ and how the "dynamic programming" algorithm runs in $O((nB)^{m+1})$. [1]: https://i.stack.imgur.com/3tlPg.png
Papadimitriou's pseudopolynomial algorithm for m x n integer program with fixed m
|algorithms|complexity-theory|linear-programming|
null
[Savitch's Theorem][1] states that $NSPACE\left( f \left( n \right)\right) \subseteq DSPACE\left( \left( f \left(n \right) \right)^2 \right)$ for any $f\left(n \right) \in \Omega \left( \log{n} \right)$. The proof I am familiar with states the following: we are given a non-deterministic turing machine $N$ for our l...
A small issue regarding the proof of Savitch's Theorem
|complexity-theory|turing-machines|space-complexity|nondeterminism|
null
If $A[\text{mid}] < B[\text{mid}]$ then you can recurse on $A[\text{mid}+1, \dots, n]$ and $B[\text{mid}+1, \dots,n]$ since, if an envyless cut exists, it must be after location $mid$. The situation $A[\text{mid}] > B[\text{mid}]$ is symmetric and you can recurse on $A[0, \dots, \text{mid}-1]$ and $B[0, \dots, \text...
**Lemma**: let $N$ be a deterministic Turing machine running in space $f(n)$. Then it is possible to know if there is a transition between two configurations (that both use space $\leqslant f(n)$) in space $\mathcal{O}(f(n))$. **Proof**: Using alphabet $\{0,1\}$, a configuration can be encoded using the tape content...
The subset sum problem is: given a list of $n$ positive integers, and a positive number $T$, find a sub-list with largest sum that is at most $T$. The problem can be found in time polynomial in $n$ and $T$ by dynamic programming: for each integer between $1$ and $T$, record whether or not there is a subset with this su...
Is there a pseudopolynomial time algorithm for this subset sum variant?
|dynamic-programming|subset-sum|pseudo-polynomial|
null
Using IEEE 754 algorithm i assume, that it can be implemented in a branchless way. But how does CPU determine special cases (Reserved Exponent values): | Exponent | Significand | is | | -------- | ----------- | -- | | 11111111 | 000000000...| Inf| | 11111111 | 00000**1**000...| NaN | | 00000000 | 000000000......
How does CPU determine Reserved Exponent cases?
|cpu|floating-point|
Using IEEE 754 algorithm i assume, that it can be implemented in a branchless way. But how does CPU determine special cases (Reserved Exponent values): | Exponent | Significand | is | | -------- | ----------- | -- | | 11111111 | 000000000...| Inf| | 11111111 | 00000**1**000...| NaN | | 00000000 | 000000000......
Consider the following proof from Papadimitriou's "On the Complexity of Integer Programming": [![enter image description here][1]][1] It is not clear to me how: - $|S_J| \le (nB)^m$ - the "dynamic programming" algorithm runs in $O((nB)^{m+1})$. [1]: https://i.stack.imgur.com/3tlPg.png
Consider the following proof from Papadimitriou's "On the Complexity of Integer Programming": [![enter image description here][1]][1] I think $|S_J| \le (nB)^m$ since there are at most $nB$ vectors of the form $v_ix_i$. In the worst case, the sums of $m$ of them are all distinct. Thus, we would have $(nB) \cdot \...
null
I have this recursive formula $$T\left(n\right)=T\left(\frac{n}{2}\right)+O\left(n\right)+O\left(n\right)+2O\left(1\right) \ \ \ ➜ \ \ \ T\left(n\right)=T\left(\frac{n}{2}\right)+O\left(n\right)$$ $$T\left(n\right) =T\left(1\right)\ +\ c_{2}n\cdot\sum_{k=1}^{⌊\log n⌋}\frac{1}{2^{k}}=T\left(1\right)+c_{2}(n-1)$$ ...
|recursion|induction|
Consider the following proof from Papadimitriou's "On the Complexity of Integer Programming": --------------------------- **Corollary 1.** There is a pseudopolynomial algorithm for solving m x n integer programs, with fixed m. **Proof.** We can solve the m x n integer program Ax = b by dynamic programming, pro...
null
A chain-complete partial order (equivalently, a pointed dcpo) is a set $D$ with a partial order $\leq$ such that all chains of $D$ have a supremum. The least upper bound ($\bigsqcup$) of the empty chain is the least element $\bot$ of the CCPO. A function $f\colon M \to N$ is monotone if for all $a, b \in M$, the fol...
Are all Scott-continuous functions computable?
|computability|
$\newcommand{\TM}{T\!M}$ Let $\TM$ be the set of Turing machines and $2 = \{0,1\}$. The powerset of any set with $\leq$ equal to $\subseteq$ is a CCPO, its least upper bounds being the unions of the chains. Take the function $f\colon P(\TM) \to P(\TM \times 2)$ that maps a set of Turing machines $S$ to $$\{ (...
Python version of what I think gnasher729 described: ``` def compute_passes(A): n = len(A) I = sorted(range(n), key=A.__getitem__) return n and min(max(j - i for i, j in enumerate(I)) + 1, n - 1) ``` Tests with various lists (showing the kind of order, whether all results were correct, and the result...
null
Not really. There are eight bits to check in two numbers usually to see there is a special case. For infinity/NaN you don’t need to do the normal operation anymore, so the rest is not time critical. More time critical is normalising the mantissa for a zero exponent. But there are processors that assumed these case...
null
Using IEEE 754 algorithm i assume, that it can be implemented in a branchless way. But how does CPU determine special cases (Reserved Exponent values): | Exponent | Significand | is | | -------- | ----------- | -- | | 11111111 | 000000000...| Inf| | 11111111 | 00000**1**000...| NaN | | 00000000 | 000000000......
Using IEEE 754 algorithm i assume, that it can be implemented in a branchless way. But how does CPU determine special cases (Reserved Exponent values): | Exponent | Significand | is | | -------- | ----------- | -- | | 11111111 | 000000000...| Inf| | 11111111 | 00000**1**000...| NaN | | 00000000 | 000000000......
Ultimately this is a question for the person who posed the exercise. They need to specify if they are asking "Is H non-universal for all m?" or if they are asking "Is H universal for all m?" If they're asking the former, then you proving H is non-universal for m = 12 is not enough. If they're asking the latter, it i...
Write code for heap sort or copy it from somewhere and run some tests to make sure it is correct. Then analyse the code. You will find there are lots of operations that run in O(log n), and you’ll need O(n) of them.
null
null
In university, I was taught the computational model hierarchy given in the following figure: https://devopedia.org/images/article/210/7090.1571152901.jpg Essentialy, Pushdown Automata (PA) can solve more problems (i.e. recognize more languages) than Finite State Machines (FSM), Turing machines (TM) can solve more pr...
Models of computation and cardinality
|turing-machines|computability|theory|
In Agda, if I disable axiom $\mathbb{K}$ I'm not able to prove $$ \forall\{A : \textbf{Set}\}\{a\ b : A\}\{p\ q : a \equiv b\} \to p \equiv q, $$ which I guess is normal since the system does not truncate equalities. However, I'm still able to prove transitivity $$ \forall \{A : \textbf{Set}\}\{a\ b\ c : A\} \to ...
Proving transitivity in an intuitionistic type theory without the K rule
|type-theory|functional-programming|dependent-types|proof-assistants|agda|
null
#### Cardinality is a Weak Property As described in the question, cardinality is a very weak property. It is not strong enough to distinguish $s(FSM)$, $s(PA)$, $s(TM)$. It cannot differentiate any two different sets that are both countably infinite. That is not surprising at all. For example, we know that $$\ma...
null
In university, I was taught the computational model hierarchy given in the following figure: https://devopedia.org/images/article/210/7090.1571152901.jpg Essentially, Pushdown Automata (PDA) can solve more problems (i.e. recognize more languages) than Finite State Machines (FSM), Turing machines (TM) can solve more ...
Sets of problems in different models of computation and cardinality
|turing-machines|computability|finite-automata|pushdown-automata|infinity|
#### Cardinality is a Weak Property As described in the question, cardinality is a very weak property. It is not strong enough to distinguish $s(FSM)$, $s(PDA)$, $s(TM)$. It cannot differentiate any two different sets that are both countably infinite. That is not surprising at all. For example, we know that $$\m...
null
$\newcommand{\J}{\mathsf{J}} \newcommand{\K}{\mathsf{K}} \newcommand{\refl}{\mathsf{refl}}$ Yes, this just uses axiom $\J$. $\K$ is only necessary for translating certain particular cases of pattern matching. $\J$ works when you have an identity like $p : E \equiv a$, where $a$ is a variable that doesn't occur in...
But I think this is possible in $O(log(n))$. Since, you can set C=A (suppose that we have no duplicate in A) and then for addition of each member from B to C it is sufficient to search it in sorted array A and if it was not in A then add the member to C.
But I think this is possible in $O(n(log(n)))$. Since, you can set C=A (suppose that we have no duplicate in A) and then for addition of each member from B to C it is sufficient to search it in sorted array A and if it was not in A then add the member to C.
null
null
{"OriginalQuestionIds":[151759],"Voters":[{"Id":755,"DisplayName":"D.W.","BindingReason":{"GoldTagBadge":"algorithms"}}]}
null
null
null
**Question 1** I think your definition of *better* is too strict in the sense that *finite* is too restrictive (but I don't have any better definition). We build a family of mazes $R=(R_i)_i$. Each one $R_i$ is a corridor of length $i$ that ends with a turn on the right. The same with $L$ and left, respectively. ...
null
Applications that allow to create formal proofs. They assist the user by finding partial and checking complete proofs. General questions about proof assistants can also be asked on the Proof Assistants Stack Exchange site.
null
The following question was sent to me by a friend and I didn't really ask him about its source so I couldn't provide the source of it. I solved the question and I need to ensure my answer not just for him but also for myself since it's important to me too. ***Question:*** Prove or Disprove: if $L$ is a decidable lan...
null
There is a paper that did a good experiment over these string matching algorithms for different patterns: "[Comparison of string matching algorithms: an aid to information content security][1]" Also there is a study of these string matching algorithms for Japanese language: [Comparison and Improvement of String Ma...
null
* Insert: $\mathcal{O}(\log n)$ * Get-Min: $\mathcal{O}(1)$ * Extract-Min: $\mathcal{O}(1)$ <h3>Amortized Time</h3> Simple implementations of a priority queue (e.g. any balanced BST, or the standard binary min-heap) can achieve these (amortized) running times by simply charging the cost of Extract-Min to insert...
null
null
AVL trees are height balanced binary search trees. As a consequence of this balance, the height of an AVL tree is logaritmic in its number of nodes. Then, searching and updating AVL-trees can be efficiently done. The fact that AVL-trees have logaritmic height can be shown by analyzing "minimal" AVL-trees, where for ...
logarithmic height AVL trees
|algorithm-analysis|avl-trees|
The subset sum problem is: given a list of $n$ positive integers, and a positive number $T$, find a sub-list with largest sum that is at most $T$. The problem can be found in time polynomial in $n$ and $T$ by dynamic programming: for each integer between $1$ and $T$, record whether or not there is a subset with this su...
AVL trees are height balanced binary search trees. As a consequence of this balance, the height of an AVL tree is logaritmic in its number of nodes. Then, searching and updating AVL-trees can be efficiently done. The fact that AVL-trees have logaritmic height can be shown by analyzing "minimal" AVL-trees, where for ...
null
First time posting on here; if this question is too rough I would appreciate if you could point me to a stackexchange forum where this question may be a better fit. Generative adversarial networks (GANs), [introduced here](https://proceedings.neurips.cc/paper/2014/hash/5ca3e9b122f61f8f06494c97b1afccf3-Abstract.html)...
Are there computational complexity results for generative adversarial networks?
|time-complexity|p-vs-np|game-theory|
First time posting on here; if this question is too rough I would appreciate if you could point me to a stackexchange forum where this question may be a better fit. Generative adversarial networks (GANs), [introduced here](https://proceedings.neurips.cc/paper/2014/hash/5ca3e9b122f61f8f06494c97b1afccf3-Abstract.html)...
null
Given an array of numbers with length $n=3^k$, we try to find an element that occurs more than $\frac{n}{3}$ times. So work as follow: > > We divide the array into 3 parts of equal length. Find > recursively a candidate $x$ in each partition and do a scan on > array to find number of occurrence of each candidat...
Modification on Boyer Moore Algorithm to find an element that occurs more than n/3 times
|algorithms|time-complexity|divide-and-conquer|
null
I am writing a blockchain as a side project in Go and I am struggling to find good a theoretical treatise on the subject. The information online is either too basic or too specific. Thanks
CLRS like book for blockchain?