instruction stringlengths 0 29.8k ⌀ |
|---|
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 |
I was about to complain that this statement:
>Then, I can prove that $Pr[S \cap N^{+}(v) \ne \emptyset]$ for every $v$ with high probability
is probably wrong, because it would imply a stronger result, namely that nearly regular graphs have a $(2, 1)$ ruling set w.h.p.
But then I realised that, not only does t... |
null |
This is one of the 800 possible optimal (2-colour) solutions (including reflections and rotations) to the 4x4 problem, found using an exhaustive search:
[![enter image description here][1]][1]
The optimality is because 16 cells require 16 distinct 4-digit labels, which exhausts the set of 4-bit patterns. The next... |
null |
Each *Even* column of corners (blue arrows) encodes a single unique ‘X’ indicator: x0,x2,x4… (here colored using Red, Green, Blue)
Each *Odd* column of corners (yellow arrows) encode a semi-incrementing ‘y’ indicator y0,y0,y1,y1,y2,y2 (here colored using Cyan, Magenta, Yellow)
Resulting set of required unique s... |
Each *Even* column of corners (blue arrows) encodes a single unique ‘X’ indicator: x0,x2,x4… (here colored using Red, Green, Blue)
Each *Odd* column of corners (yellow arrows) encode a semi-incrementing ‘y’ indicator y0,y0,y1,y1,y2,y2 (here colored using Cyan, Magenta, Yellow)
Resulting set of required unique s... |
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 $\mathcal{O}(M... |
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... |
Each *Even* column of corners (blue arrows) encodes a single unique ‘X’ indicator: x0,x2,x4… (here colored using Red, Green, Blue)
Each *Odd* column of corners (yellow arrows) encode a semi-incrementing ‘y’ indicator y0,y0,y1,y1,y2,y2 (here colored using Cyan, Magenta, Yellow)
Resulting set of required unique s... |
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 specific $(2,O(\log n))$ ruling set with high probability |
null |
Edit: my answer applies to the first post before modification.
It seems to me that your grammar is not correct. For example, if you use the first rule for $S$ and then the second rule for $S$, you get $aabcXY$ and no rule can be applied from there.
Inspired by what you proposed, it seems that the following rules ... |
null |
I have a problem where I need to find all subsets of a set that satisfy some validity function. The function has the property that if a subset is invalid, so are all its supersets, and if a subset is valid, so are all its sub-subsets.
This can clearly take exponential time if, for instance, all subsets are valid. Ho... |
Looking for all "valid" combinations taken from a set of things, where subsets of "valid" things are always "valid" |
|algorithms|reference-request|combinatorics|enumeration| |
I am learning about computational models, I wonder why Turing chose his model of Turing machines (the strip with the head and Read / Move left or right / Change state).
I am suspecting his physical machine Enigma was having a stripe and behaved similarly. Is this correct?
The circuit gates model seems close to wh... |
Why the Turing machine model is relevant? |
|turing-machines|computation-models| |
null |
null |
In the dragon book, section 9.2.6, why is the $OUT[B]$ initialized to $U$ except for $OUT[ENTRY]$. Wouldn't using the $OUT[B] = \emptyset \quad \forall B$ be a more conservative solution? The book gives this example:
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/7FNjR.png
Let
$IN[... |
Dataflow Analysis: Available Expressions, why is OUT[B] initialized to universal set? |
|compilers|data-flow-analysis| |
I'm trying to understand how the system's call stack works internally when a
recursive function is called. Specifically, I'm looking at a function that
computes the maximum depth of a binary tree using a postorder traversal.
I do know there is a stack solution out there, but I would one that mimics the internal ca... |
Understanding the Internal Stack Frames in a Recursive Function Call |
|algorithms|data-structures|recursion|binary-trees| |
The Turing machine is a very simple concept, based on two components: the program (a finite state machine) and an infinite memory (the strip). The FMSs were well-known at the time of Turing, as were the pushdown automata (a refinement of the former). Replacing the stack (of the SA) by a strip increases the power of the... |
null |
null |
A solution should be like:
Assign the probability $p_i$ to the element $i$ equal to the normalized weight, $\dfrac{w_i}{w}$. Then perform $n$ systematic drawings that accept the element $i$ with probability $p_i=kw_i$, in turn. Then the expectation of the number of elements drawn is $k$ and the distribution is honor... |
null |
>Do the given functions $f(n)=n\log n,g(n)=10n\log10n$ satisfy $f=\Theta(g)$
I think I need to prove that there exists $c_1,c_2>0$ such that $c_1.g(n)\le f(n)\le c_2.g(n)$
*Step 1*
$$
\log n\le \log 10n\implies f(n)=n\log n\le 10n\log 10n=g(n)\\
f(n)\le c_2.g(n)\implies f=O(g)
$$
*Step 2*
$$
n\log n\... |
Do the given functions $f(n)=n\log n,g(n)=10n\log10n$ satisfy $f=\Theta(g)$ |
|algorithms|time-complexity|big-o-notation| |
null |
To find out the seats occupied in each trip, you can use the following algorithm:
**Step 1.** Initialize an empty array or list to store the seats occupied in each trip.
**Step 2.** Create a 2D array or matrix to represent the stops and trips. The rows represent the stops, and the columns represent the trips.
... |
As constant factors do not matter, you can read the question as asking if
$$\log n=\Theta(\log n+c),$$ where $c>0$.
In other words
$$a(\log n+c)\le \log n\le b(\log n+c)$$ or
$$a+\frac{ac}{\log n}\le 1\le b+\frac{bc}{\log n}.$$
Now take $\log n_0=c$ so that
$$n>n_0\implies0<\frac c{\log n}<1$$ and yo... |
{"Voters":[{"Id":16034,"DisplayName":"Yves Daoust"}],"DeleteType":1} |
{"Voters":[{"Id":16034,"DisplayName":"Yves Daoust"}]} |
null |
>Do the given functions $f(n)=n\log n,g(n)=10n\log10n$ satisfy $f=\Theta(g)$
I think I need to prove that there exists $c_1,c_2>0$ such that $c_1.g(n)\le f(n)\le c_2.g(n)$
*Step 1*
$$
\log n\le \log 10n\implies f(n)=n\log n\le 10n\log 10n=g(n)\\
f(n)\le c_2.g(n)\implies f=O(g)
$$
*Step 2*
$$
n\log n\... |
It might be helpful to think of call-stack frames as remembering "where to return to" when a function call returns. There are two recursive calls in your example (one for the left child, and one for the right), so there are two possibilities of where those calls should return to.
Let's label these two return points,... |
I was learning about Red Black Trees on my own. When one opens the [Wikipedia article][1], it can be read:
>(Conclusion) If a node N has exactly one child, it **must be a red child**, because if it were black, its NIL descendants would sit at a different black depth than N's NIL child, violating requirement 4.
I ... |
Can a Red Black Tree have a node with exactly one black child? Is this image wrong? |
|binary-search-trees|red-black-trees| |
null |
How the story begins? I was learning about Red Black Trees on my own. When one opens the [Wikipedia article][1], it can be read:
>(Conclusion) If a node N has exactly one child, it **must be a red child**, because if it were black, its NIL descendants would sit at a different black depth than N's NIL child, violatin... |
Can a Red Black Tree have a black node with a black descendant? Is this image wrong? |
How the story begins? I was learning about Red Black Trees on my own. When one opens the [Wikipedia article][1], it can be read:
>(Conclusion) If a node N has exactly one child, it **must be a red child**, because if it were black, its NIL descendants would sit at a different black depth than N's NIL child, violatin... |
null |
null |
Are there known algorithms to find a line that intersects a given set of segments?
I've tried wiki and general algorithms books but found none. |
Are there known algorithms to find a line that intersects a given set of segments? |
null |
This can be formulated as finding all minimal subsets for a monotone function. Here monotone captures your property about supersets and subsets.
Or, this can be formulated exact interactive learning of a DNF representation of a monotone Boolean function $f:\{0,1\}^n \to \{0,1\}$, i.e., given ability to evaluate a m... |
**Question**: What are the current main challenges in TCP congestion control algorithms? Are there any foundational trade offs that algorithms need to make? E.g. minimizing router buffer sizes while quickly reacting to available bandwidth on noisy links?
**Context**: I was reading some of the old discussions from 20... |
Current research in TCP congestion control? |
|computer-networks|tcp| |
I can solve the following problem by by Jeff Erickson in $O(n^3)$(and maybe in $O(n^2logn)$) time but how is the $O(n^{3/2} log(n))$ time solution possible?
> Let $D[1 .. n]$ be an array of digits, each an integer between $0$ and $9$. A **digital subsequence** of $D$ is a sequence of positive integers composed in the ... |
How can this problem be solved in $O(n^{3/2}log(n))$ time? |
|algorithms|time-complexity| |
I can solve the following problem by Jeff Erickson in $O(n^3)$(and maybe in $O(n^2logn)$) time but how is the $O(n^{3/2} log(n))$ time solution possible?
> Let $D[1 .. n]$ be an array of digits, each an integer between $0$ and $9$. A **digital subsequence** of $D$ is a sequence of positive integers composed in the usu... |
>How do I Verify that $n\log n=\Theta(10n\log10n)$
I think I need to prove that there exists $c_1,c_2>0$ such that $c_1.g(n)\le f(n)\le c_2.g(n)$
*Step 1*
$$
\log n\le \log 10n\implies f(n)=n\log n\le 10n\log 10n=g(n)\\
f(n)\le c_2.g(n)\implies f=O(g)
$$
*Step 2*
$$
n\log n\ge\frac{1}{10\log 10}\big[... |
Verify $n\log n=\Theta(10n\log10n)$ |
I'm writing a graph traversal function to be used in a garbage collector.
To avoid stack overflow, I used a finite state machine. Roughly, it descends into child nodes recursively to mark objects, and return to root whenever a branch is exshausted.
However, I realized that if there's loop in the graph, it cannot... |
Does graph traversal require stack machine? |
|finite-automata|graph-traversal|stacks| |
> as it cannot distinguish a node marked for traversal in its children/descendents from a node that it had visited before.
This can be fixed by traversing a list of nodes it's visiting, starting from root - this list doesn't have to be stored, restarting from root and iterating forward is sufficient; when a node fou... |
null |
I can solve the following [problem by Jeff Erickson][1] in $O(n^3)$(and maybe in $O(n^2logn)$) time but how is the $O(n^{3/2} log(n))$ time solution possible?
> Let $D[1 .. n]$ be an array of digits, each an integer between $0$ and $9$. A **digital subsequence** of $D$ is a sequence of positive integers composed in th... |
You can solve the problem using at most $\left\lceil \sqrt{2X} \right\rceil + \left\lceil \sqrt{2Y} \right\rceil + 3$ identifiers as follows:
*PART 1:*
Let $G$ be a complete graph over $\left\lceil \sqrt{2X} \right\rceil + 1$ vertices if the $\left\lceil \sqrt{2X} \right\rceil + 1$ is odd; otherwise $G$ be a comp... |
I have a doubt related to pumping lemma in CFL for which I dont find an answer, so I think is very easy because no one wonder about. The lemma says:
[![For every context-free language L, there exists a number m such that for every long string s in L (|s| > m][1]][1]
[1]: https://i.stack.imgur.com/Mpj2O.png
... |
Doubt in pumping lema for context-free language |
|context-free|formal-grammars|pumping-lemma| |
null |
I have a doubt related to pumping lemma in CFL for which I dont find an answer, so I think is very easy because no one wonder about. The lemma says:
[![For every context-free language L, there exists a number m such that for every long string s in L (|s| > m][1]][1]
[1]: https://i.stack.imgur.com/Mpj2O.png
... |
You can solve the problem using at most $\left\lceil \sqrt{2X} \right\rceil + \left\lceil \sqrt{2Y} \right\rceil + 3$ identifiers as follows:
*PART 1:*
Let $G$ be a complete graph over $\left\lceil \sqrt{2X} \right\rceil + 1$ vertices if the $\left\lceil \sqrt{2X} \right\rceil + 1$ is odd; otherwise $G$ be a comp... |
I'm writing a graph traversal function to be used in a garbage collector.
To avoid stack overflow, I used a finite state machine. Roughly, it descends into child nodes recursively to mark objects, and return to root (to descent down again) whenever a branch is exshausted.
However, I realized that if there's loop... |
They can be empty, but the pumping lemma is used to prove that a language is *not* context free.
It says that if a language is context free, such a configuration always exist, and it's the case for $a^nb^n$ as one can take $u=a^{n-1}, v=a, w=\varepsilon, x=b, y=b^{n-1}$.
The lemma says that one such configuration e... |
null |
null |
My textbook gives the equation for the power dissipation
$$ P=CV^2 f $$
but after reading it a couple times, I can't get very clear on exactly what each of these is measuring. It describes $P$ as the "power dissipation", which I take to mean something like the heat lost to the environment as the current passes thro... |
The definitions of terms in $P=CV^2f$ |
|digital-circuits|power-consumption| |
null |
Both MAX-CUT and MAX-3-CUT are known to be NP-complete. [This post][1] shows a reduction from MAX-CUT to MAX-3-CUT. I am curious if there is a way to reduce MAX-3-CUT to MAX-CUT?
**MAX-CUT:** Given an undirected graph $G=(V,E)$, a weight function $w:E\to\mathbb{N}$, and $k\in\mathbb{N}$, determine if there exists a ... |
Reduction from MAX-3-CUT to MAX-CUT |
|complexity-theory|optimization|reductions|discrete-mathematics|max-cut| |
null |
null |
I will assume you know how to solve the problem by keeping a table $T[i, j]$
which stores the length of the best solution whose last integer is $D[i\cdots j] = D[i]D[i+1] \cdots D[j]$. To compute $T[i, j]$ you need to find the best $T[a, b]$ such that $D[a \cdots b] <_{\text{lex}} D[i \cdots j]$ and $b < i$. The compu... |
I have recently reviewed the new article by DeepMind (Google) in Nature named "[Faster sorting algorithms discovered using deep reinforcement learning][1]". They claim that branchless algorithms, such as sort4, maintain full correlation between the algorithm length and its latency (Table B.5 in the [supplementary mater... |
Solving possible inconsistency in the new Nature article by Google (Faster sorting algorithms discovered using deep reinforcement learning) |
|algorithms|sorting| |
Correlation between branchless algorithm length (Assembly) and its latency |
Using an answer to write down a nice insight, inspired by the comments:
**Definition**. A function $f: \Sigma^s \to \{0, ..., s-1\}$ is called *shift-invariant* if $\forall w \in \Sigma^s, c \in \Sigma: f(w_0...w_{s-1}) > 0 \Rightarrow f(w_1...w_{s-1}c) = f(w_0...w_{s-1}) - 1$.
**Definition**. For a finite set of... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.