instruction stringlengths 0 29.8k ⌀ |
|---|
The [happened-before](https://en.wikipedia.org/wiki/Happened-before) relation is a standard mathematical tool for reasoning about time ordering of events in distributed systems. You can find a lot of development on foundations of it, tools for tracking it, and systems built on this concept.
[Timestamping](https://e... |
As far as a CPU is concerned, everything is bits/bytes/words in memory. It doesn't "know" what the contents of a memory location means.
CPUs do have instructions that operate differently on (say) signed and unsigned integers. For example, it might have separate instructions for:
- Signed vs unsigned multiplicati... |
|computer-architecture|binary| |
{"OriginalQuestionIds":[105398],"Voters":[{"Id":755,"DisplayName":"D.W."}]} |
One pragmatic approach is to use a dynamic array $A$. Store the integers in sorted order in this array. Augment this data structure with two additional indices: $i_\min$ (the index of the smallest element in the set), and $i_\max$ (the index of the largest element in the set, plus one).
Then, the predecessor opera... |
Algorithm design is known to be an art. There is no magical recipe. It all depends on the mathematical properties of the problems addressed.
In the case of sorting, the designers were helped by a few theoretical considerations:
- there are $n!$ ways to permute an array, so any sort that relies on comparisons (eac... |
It definitely isn't $O(n)$, it's rather $\Omega (n)$. $O(n^2)$, $O(n^{1+\log_3{2}})$ (and not $O(n^{1.63})$, thanks to the comments) are both correct, with $O(n^{1.63})$ being the tighter upper bound of the two, and the tightest upper bound in this particular example. |
null |
null |
Faster CPUs solve the same computational problems in shorter time frames. The same applies to faster GPUs.
Therefore, replacing with faster components can reduce the computer's power consumption.
On the other hand do some components need more electrical power for instance for ventilation.
How do you estimate w... |
Estimate which components to replace, to not only save electric energy but also improve the computer's performance |
|optimization|power-consumption| |
Is the complexity of $F(n) = n \cdot n^{\log_3 2}$ allowed to be written as $O(n)$, or must you specify and say $O(n^{1.63})$, or even must you write $O(n^2)$ since it is an upper bound? |
Asymptotics of $F(n) = n \times n^{\log_32}$ |
|big-o-notation| |
It definitely isn't $O(n)$, it's rather $\Omega (n)$. $O(n^2)$, $O(n^{1+\log_3{2}})$ (and not $O(n^{1.63})$, thanks to the comments) are both correct, with $O(n^{1 + \log_32})$ being the tighter upper bound of the two, and the tightest upper bound in this particular example. |
null |
Replacing components in an existing computer with different ones is often hard to impossible.
CPUs usually don't have fixed performance at fixed use of electricity, but there is a curve where you change the voltage of the CPU, and it increases both performance (linear) and power usage (quadratic). The limits are at... |
I noticed that when you compress data they can compress multiple files and since all files are made up of bytes how do these compression algorithms keep track of them? What seperators do they use?
From my understanding it goes like this, for example I have an array [1,2,3] and another array [4,12,6] and I store them... |
How do compression algorithms keep track of multiple files? |
|data-compression| |
If $f(n)=O(n^\alpha)$ (your exponent, $\approx1.63$), then certainly $f(n)=O(n^2)$. But you may not conclude $f(n)=O(n)$. If you want to keep the available information, stick to $O(n^\alpha)$. The exponent needs not be integer.
|
A simple method: You create an algorithm first that can translate a sequence of bytes into a compressed sequence, and can decompress the compressed sequence into the original file if the length is known.
Then let's say you have ten files: You get their filenames, and a compressed sequence for each file. The output ... |
null |
null |
null |
It's really hard. As a first approximation, my sense is that you basically can't, in any reliable, scientific way, in most cases. Modern computers are complex, and it's hard for an average consumer to predict exactly what the impact on performance or energy usage will be of any particular change to one component. In... |
I'm required to describe an implementation of a data structure that holds key,value pairs, which can be **signed integers**.
We need to be able to init() in O(1), insert(x) in O(logn), delete(x) in O(logn) and sumPrevious(x), which returns sum of **values** of the keys that are smaller than key 'x', in O(logn).
An ... |
Find a key in a BBST for which sum of values of keys smaller then it - is maximal |
|avl-trees|rank| |
null |
null |
I am trying to understand how `(n-m+1)` (`n` being the string and `m` being the pattern) is derived. As in, how could you determine a formula for the number of comparisons in the worst case of a brute-force string matching algorithm. |
Derive the formula (n-m+1) number of comparisons for worst case Brute-force string matching algorithm |
|algorithms|algorithm-analysis| |
You have a problem with multiple numbers involved. You want an algorithm that is polynomial in one of the numbers, and the logarithm of the other numbers.
In this case, since the $a_i$ are all positive, they must all be <= b, otherwise there is no solution. So the values of all the numbers are severely restricted, ... |
I am trying to understand how `(n-m+1)` (`n` being the string and `m` being the pattern) is derived. As in, how could you determine a formula for the number of comparisons in the worst case of a brute-force string matching algorithm.
With the ultimate goal of seeing where in the process of deriving the formula, the ... |
Go back to how the pumping lemma is created: If L is regular then there is a state machine recognising L with p states. If you process the first n characters of a string, you must visit at least one state twice. If you moved from state X to state X while processing k >= 1 characters, then leaving these characters out, ... |
Let $\mathcal{A} \subseteq \mathcal{B}$ given as a collection of arrays. The degree of an element $a \in \cup \mathcal{A}$, is the number of sets of $\mathcal{A}$ that it contains - that is, $d_{\mathcal{G}(x)} =|D_{\mathcal{G}}(x)|$, where $D_{\mathcal{G}} =\{A \in \mathcal{G} \mid a \in A\}$. The algorithms is as fol... |
Runtime Analysis of Uniform Sampling via exact degree computation |
|runtime-analysis|randomized-algorithms| |
I am currently experimenting on compression algorithms, I am using proven algorithms and I am just trying to see if I can make some things more efficient, so I am very sorry if this is a stupid question. I am trying to decode an array from a string for example I have `[123, 4, 12, 7, 51]` so if I turn this into a strin... |
Is it possible to decode an array stored in strings with constraints? |
|algorithms|data-structures|data-compression| |
Is it possible to decode an array stored in strings with constraint satisfaction? |
I am currently experimenting on compression algorithms, I am using proven algorithms and I am just trying to see if I can make some things more efficient, so I am very sorry if this is a stupid question. I am trying to decode an array from a string for example I have `[123, 4, 12, 7, 51]` so if I turn this into a strin... |
I’d look first at Huffman coding and arithmetic coding, which will handle th commas and spaces quite efficiently. Or Lempel-Ziv which munches these separators away at practically no cost.
Or encode the integers as UTF-8, extended to 5 or 6 byte codes in case you have some huge integers. |
I want to analyse the time complexity for Unsuccesful search using probabilistic method in a Hash table where collisions are resolved by chaining through a doubly linked list. And the doubly linked list is kept in sorted order (Ascending).
I proceeded in the following way: We will stop if the element in the linked ... |
Time complexity analysis for Searching in a Hash table |
|algorithms|time-complexity|data-structures|probabilistic-algorithms|hashing| |
Let $\mathcal{A} \subseteq \mathcal{B}$ given as a collection of arrays. The degree of an element $a \in \cup \mathcal{A}$, is the number of sets of $\mathcal{A}$ that it contains - that is, $d_{\mathcal{A}(x)} =|D_{\mathcal{A}}(x)|$, where $D_{\mathcal{A}} =\{A \in \mathcal{A} \mid a \in A\}$. The algorithms is as fol... |
Let $\mathcal{A} \subseteq \mathcal{B}$ given as a collection of arrays. The degree of an element $a \in \cup \mathcal{A}$, is the number of sets of $\mathcal{A}$ that it contains - that is, $d_{\mathcal{A}(x)} =|D_{\mathcal{A}}(x)|$, where $D_{\mathcal{A}} =\{A \in \mathcal{A} \mid a \in A\}$. The algorithms is as fol... |
I want to analyse the time complexity for Unsuccesful search using probabilistic method in a Hash table where collisions are resolved by chaining through a doubly linked list. And the doubly linked list is kept in sorted order (Ascending).
I proceeded in the following way: We will stop if the element in the linked ... |
I want to analyse the time complexity for Unsuccesful search using probabilistic method in a Hash table where collisions are resolved by chaining through a doubly linked list. And the doubly linked list is kept in sorted order (Ascending).
I proceeded in the following way: We will stop if the element in the linked ... |
null |
Let $\alpha = \frac{n}{m}\ $ (where $n\ = total\ number\ of\ elements,\ m = number\ of\ slots\ in\ hashtable)$, be the $load\ factor$ or $Average\ number\ of\ elements\ in\ a\ chain$.
Given that each chain is sorted, an unsuccessful attempt at search would require $1$ comparison in the best case and $\alpha$ compar... |
Let $\alpha = \frac{n}{m}\ $ (where $n\ = total\ number\ of\ elements,\ m = number\ of\ slots\ in\ hashtable)$, be the $load\ factor$ or $Average\ number\ of\ elements\ in\ a\ chain$.
Given that each chain is sorted, an unsuccessful attempt at search would require $1$ comparison in the best case and $\alpha$ compar... |
Let $\alpha = \frac{n}{m}\ $ where $n$ = total no. of elements in hashtable ,$m$ = number of slots in hashtable, be the *load factor* or *Average number of elements in a chain*.
Given that each chain is sorted, an unsuccessful attempt at search would require $1$ comparison in the best case and $\alpha$ comparisons ... |
Let $\alpha = \frac{n}{m}\ $ where $n$ = total no. of elements in hashtable ,$m$ = number of slots in hashtable, be the *load factor* or *Average number of elements in a chain*.
Given that each chain is sorted, an unsuccessful attempt at search would require $1$ comparison in the best case and $\alpha$ comparisons ... |
null |
Let $\alpha = \frac{n}{m}\ $ where $n$ = total no. of elements in hashtable ,$m$ = number of slots in hashtable, be the *load factor* or *Average number of elements in a chain*.
Given that each chain is sorted, an unsuccessful attempt at search would require $1$ comparison in the best case and $\alpha$ comparisons ... |
We know that if $T_1 = \{e_1, \dots, e_n\}$ and $T_2=\{f_1, \dots, f_n\}$ are MST then if we order the edges such as
$$e_1 \le e_2 \le \dots \le e_n$$
$$f_1 \le f_2 \le \dots \le f_n$$
then $w(e_i)=w(f_i)$ for all $i\in [n]$
This also (trivially) implies that $w(e_1) \le w(f_i)$ for all $i\in [n]$
Does this ... |
Does exist a tree where the inequality with MST edges are strict? |
|graphs|combinatorics|minimum-spanning-tree| |
null |
We know that if $T_1 = \{e_1, \dots, e_n\}$ and $T_2=\{f_1, \dots, f_n\}$ are MST then if we order the edges such as
$$e_1 \le e_2 \le \dots \le e_n$$
$$f_1 \le f_2 \le \dots \le f_n$$
then $w(e_i)=w(f_i)$ for all $i\in [n]$
This also (trivially) implies that $w(e_1) \le w(f_i)$ for all $i\in [n]$
Does this ... |
null |
null |
In relational databases, what are the practical or theoretical ways to reduce the size and spatial complexity of intermediate indexes or tables* at execution time (so for example to reduce the size of intermediate indexes when running a join on a time series data with millions of entries).
Additional research papers... |
How can we reduce the spatial complexity of intermediate indexes in relational databases at execution time? |
|complexity-theory|optimization|space-complexity|database-theory|databases| |
null |
In comparison sort, the fastest possible algorithm is order $n \log(n)$. Also this bound can be achieved by various algorithms such as quick sort. What is the time complexity of sorting a list of natural numbers, each represented as a binary string in base 2, and separated by commas. For example, the list $3,1,2$ would... |
time complexity of sorting binary natural numbers |
|sorting| |
null |
I am trying to understand how `(n-m+1)` (`n` being the string and `m` being the pattern) is derived. As in, how could you determine a formula for the number of comparisons in the worst case of a brute-force string matching algorithm.
Here is a look at `(n-m+1)` being mathmatically derived (where I'm at), that I foun... |
null |
Let $\mathcal{A} \subseteq \mathcal{B}$ given as a collection of arrays. The degree of an element $a \in \cup \mathcal{A}$, is the number of sets of $\mathcal{A}$ that it contains - that is, $d_{\mathcal{A}(x)} =|D_{\mathcal{A}}(x)|$, where $D_{\mathcal{A}} =\{A \in \mathcal{A} \mid a \in A\}$. The algorithms is as fol... |
Let $\mathcal{A} \subseteq \mathcal{B}$ given as a collection of arrays. The degree of an element $a \in \cup \mathcal{A}$, is the number of sets of $\mathcal{A}$ that it contains - that is, $d_{\mathcal{A}(x)} =|D_{\mathcal{A}}(x)|$, where $D_{\mathcal{A}} =\{A \in \mathcal{A} \mid a \in A\}$. The algorithms is as fol... |
Let $\mathcal{A} \subseteq \mathcal{B}$ given as a collection of arrays. The degree of an element $a \in \cup \mathcal{A}$, is the number of sets of $\mathcal{A}$ that it contains - that is, $d_{\mathcal{A}(x)} =|D_{\mathcal{A}}(x)|$, where $D_{\mathcal{A}} =\{A \in \mathcal{A} \mid a \in A\}$. The algorithms is as fol... |
I'm reading *Algorithm Design and Application*, by Michael T. Goodrich and Robert Tamassia, and sometimes the pseudo-code in this book doesn't make sense at all.
At chapter one they show us 3 solutions for the famous [maximum subarray problem][1]. I understood completely the first and second solutions, but the thir... |
How can I convert this pseudo-code to Python code? |
|algorithms|python|pseudocode|maximum-subarray| |
A [post][1] claims 5 of the trees shown in the following figure are all binary search trees
[![enter image description here][2]][2]
I guess the author's making a mistake, since the 2 trees on the right ARE NOT binary search trees.
As an example, in the last tree pointed out by red rectangle, the key `1` is in ... |
All the keys in a binary search tree should be greater than or equal to the root of the tree, is my understanding correct? |
|trees| |
A [post][1] claims 5 of the trees shown in the following figure are all binary search trees
[![enter image description here][2]][2]
I guess the author's making a mistake, since the 2 trees on the right ARE NOT binary search trees.
As an example, in the last tree pointed out by red rectangle, the key `1` is in ... |
A [post][1] claims 5 of the trees shown in the following figure are all binary search trees
[![enter image description here][2]][2]
I guess the author's making a mistake, since the 2 trees on the right ARE NOT binary search trees.
As an example, in the last tree pointed out by red rectangle, the key `1` is in ... |
You are right that both trees on the right are not binary trees but you are wrong that all keys of a subtree are greater than the key at the root. It is true only for the **right** subtree. The keys of the **left** subtree are all lesser than the keys of the root. That is the very definition of a BST.
Concerning du... |
My answer is similar to @Yves Daoust, But I want to calculate the expected runtime easily.
**If key is present:**
Let $T$ be the runtime, what we want to calculate is $E[T]$.
**when $1\leq T \leq n $:**
$Pr(T\geq i)=\dfrac{n-1}{n}\dfrac{n-2}{n-1}...\dfrac{n-i+1}{n-i}=\dfrac{n-i+1}{n}$.
**when $ T \geq n ... |
What is the time complexity of the best-known algorithm to search for all or the largest complete bipartite subgraph (not induced subgraph since it is allowed to remove edges) in a given graph?
Actually I am just looking for a source which says it is NP-complete to justify my usage of an approximation algorithm |
List complete bipartite subgraphs of graph |
|graphs| |
In order to show that Lambda calculus and Turing machines are equivalent it is sufficient to show that you can emulate one in the other [both ways].
How does one emulate lambda calculus in recursion theory?
Are there any reference reading materials? |
Equivalence between Lambda Calculus [Church] and Computable Partial Functions [Godel] |
|computability|lambda-calculus|computation-models| |
How to determine if an integer x > 0 can be represented as 20n + 50m + 100k, where n,m,k >= 0 and are integers.
|
How to check if an positive integer can be represented as a sum of integers |
|algorithms|integers| |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.