instruction stringlengths 0 29.8k ⌀ |
|---|
I want to find "interesting" elements in a sequence of symbols that are independent of their absolute position in that sequence.
Formally, I have a window size $s \in \mathbb{N}$ and a finite alphabet $\Sigma$.
I'm looking for a function $f: \Sigma^s \to \{0, \; ..., \; s\}$ that points to the first interesting pos... |
null |
I want to find "interesting" elements in a sequence of symbols that are independent of their absolute position in that sequence.
Formally, I have a window size $s \in \mathbb{N}$ and a finite alphabet $\Sigma$.
I'm looking for a function $f: \Sigma^s \to \{0, \; ..., \; s\}$ that points to the first interesting pos... |
The simplest way to see that $T(n) \geq f(n)$ is to note that in the definition of the function, the only two values explicitly defined are $f(0) = 0$ and $f(1) = 1.$ All the rest are defined by adding two values together. Since the only explicitly defined, non-zero value is $f(1) = 1,$ we see at least $f(n)$ addition... |
null |
null |
null |
null |
The NMI pin on the 6502 isn't *exactly* edge-triggered. Rather, it is sampled into a latch on every cycle, and if the NMI line is asserted, the signal is held until the CPU is ready to service it.
And now, the long answer.
The 6502 timing uses a two-phase clock. The input clock signal (called $\phi_0$) is cleaned... |
The NMI pin on the 6502 isn't *exactly* edge-triggered. Rather, it is sampled into a latch on every cycle, and if the NMI line is asserted, the signal is held until the CPU is ready to service it.
And now, the long answer.
The 6502 timing uses a two-phase clock. The input clock signal (called $\phi_0$) is cleaned... |
null |
Is there a proven upper bound on the number of possible sorting algorithms that cannot be reduced to another sorting algorithm?
Sorting algorithms with useless steps wouldn't count because they can be reduced by removing the useless steps.
Wikipedia lists 44 sorting algorithms. https://en.wikipedia.org/wiki/Sorti... |
Is there an upper bound on the number of different sorting algorithms |
|algorithms|sorting| |
null |
I'm reading the [chapter][1] Radix Search of the book Algorithms (Robert Sedgwick).
I've made a simple implementation and something isn't behaving as expected.
In program `15.5` you can see that we start with an empty tree where the head is a null node. In figure `15.12` you can see that the null node is always t... |
Is this Patricia tree implementation wrong? |
|algorithms|data-structures|binary-trees|trie| |
The NMI pin on the 6502 isn't *exactly* edge-triggered. Rather, it is sampled into a latch on every cycle, and if the NMI line is asserted, the signal is held until the CPU is ready to service it.
And now, the long answer.
The 6502 timing uses a two-phase clock. The input clock signal (called $\phi_0$) is cleaned... |
null |
Distributed computing is understood as splitting a big computational task between computers on a network, to reduce the total time and share the computational resources. The whole process is organized in such a way that the subtasks are distributed to the computing nodes in a fully automated way.
Workgroup computing... |
null |
There are an infinite amount of sorting algorithms that are essentially distinct.
I sketch the argument below.
Inputs: unordered lists
Outputs: sorted list
A sorting algorithm transforms each input (a topological sort over the discrete order) into an output (a topological sort over the linear order).
Co... |
No. There are an infinite amount of sorting algorithms that are essentially distinct.
I sketch the argument below.
Inputs: unordered lists
Outputs: sorted list
A sorting algorithm transforms each input (a topological sort over the discrete order) into an output (a topological sort over the linear order).
... |
No. There are an infinite amount of sorting algorithms that are essentially distinct.
I sketch the argument below (using Yao's topological sort model).
Inputs: unordered lists
Outputs: sorted list
A sorting algorithm transforms each input (a topological sort over the discrete order) into an output (a topol... |
null |
Yes, we can do that. The basic idea is that from an arbitrary Turing machine $M$ we can produce an LBA $C$ which checks whether its input codes a valid sequence of configurations for $M$ starting with the starting state and the empty tape, and ending in a halting state. Now we have that $C$ will accept some input if an... |
In *Program 15.5* they state:
> The root of the trie is at `head.l` (the link `head.r` is
unused).
`head.l` *does* get assigned. |
null |
Imagine there's a boat with a fixed number of seats. The boat goes on a journey with n number of stops.
Here is a diagram of the journey where n = 4
[![enter image description here][1]][1]
The squares represent a stop. The lines represent a trip.
Trips occur from each stop to every other stop that comes af... |
Algorithm to find the seating capacity on each trip within a multi stop journey |
|algorithms| |
null |
Is there a proven upper bound on the number of possible sorting algorithms that cannot be reduced to another sorting algorithm?
Sorting algorithms with "useless steps" wouldn't count because they can be reduced by removing the useless steps. I define a "useless step" as something that can be removed from the algorit... |
I'm trying to do some research on graph search algorithms that are practically fast on relatively dense graphs. Besides the common ones like A* or Dijkstra's, what are some graph search algorithms that give a good enough jab at the shortest path while having performance advantages compared to Dijkstra's? |
Graph Search Algorithms that are practically fast on dense graphs |
|graphs|search-algorithms|graph-traversal|search-problem| |
I have a grid of cells, X cell wide by Y cells high. Each cell has four corners, NW, NE, SW and SE. Each corner is shared with adjacent neighbors; i.e., a cell's SW corner is the NW corner of the cell just below it.
In any grid of (X,Y) cells, there are (X+1,Y+1) corners.
In this grid, each corner can be assigned... |
Minimum Number of Unique Identifiers for a Grid of Cells |
|topology| |
No. There are an infinite amount of sorting algorithms that are essentially distinct.
I sketch the argument below (using Yao's topological sort model).
Inputs: unordered lists
Outputs: sorted list
A sorting algorithm transforms each input (a topological sort over the discrete order) into an output (a topol... |
An obvious upper bound for the number of algorithms to sort $n$ numbers is $2^{(n(n-1)/2)!}$, an astronomical number. This is simply established by considering that you can perform at most $\dfrac{n(n-1)}2$ distinct pairwise comparisons, in any order, and every comparison can have two outcomes. That makes a decision tr... |
An obvious upper bound for the number of algorithms to sort $n$ numbers is $\left(\dfrac{n(n-1)}2\right)!\,2^{(n(n-1)/2)}$, an astronomical number. This is simply established by considering that you can perform at most $\dfrac{n(n-1)}2$ distinct pairwise comparisons, in any order, and every comparison can have two outc... |
I have a grid of cells, X cells wide by Y cells high. Each cell has four corners, NW, NE, SW and SE. Each corner is shared with adjacent neighbors; i.e., a cell's SW corner is the NW corner of the cell just below it.
In any grid of (X,Y) cells, there are (X+1,Y+1) corners.
In this grid, each corner can be assigne... |
For a pragmatic solution, I suggest using a SAT solver.
Suppose we want to find a valid coloring, using $C$ colors. Let $L=\lceil \lg C \rceil$, so that each color can be encoded as a $L$-bit integer.
Let $x_{i,j,k}$ be a boolean variable, representing the $k$th bit of the color of the corner at position $(i,j)$. ... |
null |
I'm trying to do some research on graph search algorithms that are practically fast on relatively dense graphs. Besides the common ones like A* or Dijkstra's, what are some graph search algorithms that give a good enough jab at the shortest path while having performance advantages compared to Dijkstra's?
The graph i... |
null |
I am working on Ramanujan graphs and have encountered something that needs a suggestion. Does the girth of a Ramanujan graph change if I delete one random edge from the graph? <br> The question can also be as follows: are there at least two edge-disjoint shortest cycles in Ramanujan graphs? If yes, the girth does not c... |
Ramanujan graph girth comparision |
|graphs| |
In my reference, [Exercise 0.4(e), Algorithms by Sanjoy Dasgupta, Christos H. Papadimitriou, and Umesh V. Vazirani][1], it is given that
$$
\begin{bmatrix}F_n\\F_{n+1}\end{bmatrix}=\begin{bmatrix}0&1\\1&1\end{bmatrix}^n\begin{bmatrix}F_0\\F_1\end{bmatrix}
$$
Prove that the running time of $fib3$ is $O(M(n))$, whe... |
Time Complexity of Matrix Fibonacci Algorithm |
|algorithms|time-complexity|matrices| |
Let $H=\{h|h:X\to Y\}$, $|X|=n$, $|Y|=m$. $H$ is a universal hash family if
**Def 1.** For any $x_1,\ x_2\in X$, $x_1\neq x_2$, $\left|\left\{h\in H\middle| h(x_1)=h(x_2)\right\}\right|\leq |H|/m$. (or what if $=|H|/m$ ?)
**Def 2.** For any $x_1,\ x_2\in X$, $x_1\neq x_2$ and for any $y_1, y_2\in Y$,
$$
\Pr\li... |
On the equivalence between two definitions of universal hashing |
|discrete-mathematics|hash|cryptography| |
null |
An obvious upper bound for the number of programs to sort $n$ numbers is $\left(\dfrac{n(n-1)}2\right)!\,2^{(n(n-1)/2)}$, an astronomical number. This is simply established by considering that you can perform at most $\dfrac{n(n-1)}2$ distinct pairwise comparisons, in any order, and every comparison can have two outcom... |
null |
null |
To prove that the running time is $O(n^2)$, you need to observe that not every multiplication step takes $O(n^2)$ time. For example, the first matrix multiplication can be done in $O(1)$ time. If you carefully sum the complexities over all matrix multiplications, the running time would be:
$$8 \cdot (M(1) + M(2) + M... |
null |
Is time complexity of log(n+logn) is equal to theta log(n)?
Can I take only the dominants from inside of a log? |
Time complexity of log(n+logn) |
|time-complexity| |
Yes.
$$\log(n)\le\log(n+\log n)=\log n+\log\left(1+\frac{\log n}n\right)\le\log n+e^{-1}.$$
----------
More generally,
$$\log(f(n))\le\log(f(n)+g(n))=\log(f(n))+\log\left(1+\frac{g(n)}{f(n)}\right)\le \log(f(n))+\frac{g(n)}{f(n)}$$ and if the last term is $o(1)$ you can drop it. |
Yes.
$$\log(n)\le\log(n+\log n)=\log n+\log\left(1+\frac{\log n}n\right)\le\log n+\log(1+e^{-1}).$$
----------
More generally,
$$\log(f(n))\le\log(f(n)+g(n))=\log(f(n))+\log\left(1+\frac{g(n)}{f(n)}\right)\le \log(f(n))+\frac{g(n)}{f(n)}$$ and if the last term is $o(1)$ you can drop it. |
null |
null |
No. They are not equivalent. Consider $X=Y=\{0,1\}$ and $H$ contains two hash functions, $h_b(x)=x \oplus b$ where $\oplus$ represents the xor function. This satisfies definition 1, but not definition 2.
See also https://en.wikipedia.org/wiki/Universal_hashing, which explains that definition 2 is a stronger condi... |
Your upper bound is not tight. Let $n=5^k$, as in you question. You can upper bound your summation by
$$
\sum_{i=1}^{k} 5^i \cdot \log^2 5^{k-i} \le
6 \sum_{i=1}^{k} 5^i (k-i)^2 =
6 \cdot 5^{k} \sum_{i=0}^{k-1} \frac{i^2}{5^i} = 5^k \cdot O(1),
$$
where the last equality follows from the fact that the serie... |
Given a large dataset $D$ and multiple sets of filters that can be applied to $D$, e.g.
* $setA = \{filterOnColorRed\}$
* $setB = \{filterOnAgeGreaterThan20\}$
* $setC = \{filterOnColorRed, filterOnAgeGreaterThan20\}$
* $setD = \{filterOnColorRed, filterOnAgeGreaterThan20, filterOnSizeIsLarge\}$
where each fil... |
Algorithm to identify common subsets |
|graphs|sets|topological-ordering| |
Given a large dataset $D$ and multiple sets of filters that can be applied to $D$, e.g.
* $setA = \{filterOnColorRed\}$
* $setB = \{filterOnAgeGreaterThan20\}$
* $setC = \{filterOnColorRed, filterOnAgeGreaterThan20\}$
* $setD = \{filterOnColorRed, filterOnAgeGreaterThan20, filterOnSizeIsLarge\}$
where each fil... |
I am looking to provide a formula saying "A graph with $n$ vertices has an independent set $X$ of size at least $n/2$" in existentional second order logic.
(This is exercise 1.2. from Libkin's Elements of Finite Model Theory (see [here][1] for online pdf, page 10 of the book (or 23 in the pdf)).
[1]: https://... |
How to express that a graph has Independent set of size at least $n/2$ in $\exists SO$ |
|graphs|logic|finite-model-theory|independent-sets| |
Is there is an algorithm faster than combinatorial to find a line that intersects a given set of segments?
I've tried wiki and general algorithms books but found none. |
Is there is an algorithm faster than combinatorial to find a line that intersects a given set of segments? |
|computational-geometry|combinatorics| |
I suggest creating a DAG, as you suggest, with one vertex per set, and an edge from set $S$ to set $T$ if $T$ is guaranteed to be a subset of $S$ (i.e., the filters of $T$ are a superset of the filters of $S$).
Then do a topological sort on the DAG, and process the sets in topologically sorted order. When computing... |
One way to see it is to notice that asking for $|X|\ge n/2$ is the same as asking that $X$ is bigger than $V(G)\setminus X$, which can be witnessed by an injection from $V(G)\setminus X$ to $X$. Thus, the property can be expressed in the following way:
$$
\begin{align*}
|X|\ge n/2 &\iff |V\setminus X|\le|X| \\
&\... |
null |
In my reference, [Exercise 0.4(e), Algorithms by Sanjoy Dasgupta, Christos H. Papadimitriou, and Umesh V. Vazirani][1], it is given that
$$
\begin{bmatrix}F_n\\F_{n+1}\end{bmatrix}=\begin{bmatrix}0&1\\1&1\end{bmatrix}^n\begin{bmatrix}F_0\\F_1\end{bmatrix}
$$
Prove that the running time of $fib3$ is $O(M(n))$, whe... |
An $(\alpha,\beta)$-ruling set is a set $S$ such that any two nodes in $S$ are at distance at least $\alpha$ from each other, and, for any node $v \notin S$, there exists a node $u \in S$ such that the distance between $u$ and $v$ is at most $\beta$.
Let $G$ be graph which is nearly regular, with all degrees in $[k,... |
Showing that nearly regular graphs have a $(2,O(\log n))$ ruling set with high probability |
|algorithms|complexity-theory|graphs|randomized-algorithms| |
To prove that the running time is $O(n^2)$, you need to observe that not every multiplication step takes $O(n^2)$ time. For example, the first matrix multiplication can be done in $O(1)$ time. For finding all the powers $X^{2^i}$ for $i \in \{1,\dotsc,\lfloor \log n \rfloor \}$, if you carefully sum the complexities ov... |
Take a set of $n$ points in the plane. You want to sort them by increasing abscissa. But you also want to sort them by abscissa after several arbitrary rotations, say $k$, in increasing angles.
The obvious brute-force solution takes time $O(kn\log n)$. Is there a method with a better complexity ?
[![enter image d... |
Rotating sort algorithm |
|computational-geometry| |
Take a set of $n$ points in the plane. You want to sort them by increasing abscissa. But you also want to sort them by abscissa after several arbitrary rotations, say $k$, in increasing angles.
The obvious brute-force solution takes time $O(kn\log n)$. Is there a method with a better complexity ?
[![enter image d... |
Take a set of $n$ points in the plane. You want to sort them by increasing abscissa. But you also want to sort them by abscissa after several arbitrary rotations, say $k$, in increasing angles.
The obvious brute-force solution takes time $O(kn\log n)$. Is there a method with a better complexity ?
[![enter image d... |
Take a set of $n$ points in the plane. You want to sort them by increasing abscissa. But you also want to sort them by abscissa after several arbitrary rotations, say $k$, in increasing angles.
The obvious brute-force solution takes time $O(kn\log n)$. Is there a method with a better complexity ?
[![enter image d... |
Take a set of $n$ points in the plane. You want to sort them by increasing abscissa. But you also want to sort them by abscissa after several arbitrary rotations, say $k$, in increasing angles.
The obvious brute-force solution takes time $O(kn\log n)$. Is there a method with a better complexity ?
[![enter image d... |
null |
You can’t use recursive descent for two reasons: You don’t know which rule to apply until you have parsed the first var. And a recursive call must not parse the last var, or the caller will fail. Fortunately you can handle this easily in this case:
var = parse_var()
exp = make_exp(rule2, var)
while inp... |
You can prove that the optimal ordering is according to ascending order of `e(i)/f(i)`.
**Proof:**
Let `r(i) = 1 - f(i)`.
The total cost of an ordering is: `e(1) + e(2)*r(1) + e(3)*r(2)*r(1) + ... + e(N)*r(N-1)*...*r(1)`
Now, assume that there's an optimal ordering that *doesn't* follow the rule above. It fol... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.