instruction stringlengths 0 29.8k ⌀ |
|---|
Maximum of a tritonic array |
|search-algorithms|search-problem|binary-search| |
You can't. It's not possible to do this in $O(\log n)$ time.
Consider the following two possibilities for the tritonic array:
1. We have an array $A^1$ that contains the values $1,2,3,4,\dots,n$, except that at index $i$, we have the value $-1$.
1. We have an array $A^2$ that contains the values $1,2,3,4,\dot... |
null |
Give a positive $m$ by $n$ positive integers as input, choose a set of elements such that for any 2 by 2 submatrices, at most 2 elements are chosen. Return the maximum sum of chosen elements among all possible choice.
For instance, for input [[1,3,4,3],[2,5,6,7]], the answer is 2 + 5 + 6 + 7 = 20.
I feel like th... |
Find maximum sum subgrid under constraint |
|dynamic-programming| |
Give a positive $m$ by $n$ matrix as input, choose a set of elements such that for any 2 by 2 submatrices, at most 2 elements are chosen. Return the maximum sum of chosen elements among all possible choice.
For instance, for input [[1,3,4,3],[2,5,6,7]], the answer is 2 + 5 + 6 + 7 = 20.
I feel like this is a DP ... |
Firstly, note the following claim:
**Claim**: Let $S$ be any set of $n$ elements. Let $B$ be any binary tree with $n$ empty nodes. Then, there exists a mapping of $S$ to the nodes of $B$ such that $B$ is a binary search tree of set $S$.
**Proof**: The claim follows since inorder traversal of the tree can be mapp... |
I have found out how to find the maximum of a "bitonic" array. The problem is as follows.
An array is bitonic if it is comprised of an increasing or decreasing sequence of integers followed immediately by a decreasing or increasing (respectively) sequence of integers. Write a program that, given a bitonic array of n... |
The language is :
*$3COLORHC = \{<G> | \text{ G is an undirected 3-colorable graph that contains Hamiltonian cycle} \}$*
I was asked to show that this language is NP-Complete.
Showing that the language is in NP is easy, but I got stuck showing a reduction from an NP-Complete language.
I tried reducing from UH... |
Show a language is NP-Complete |
|np-complete|reductions| |
null |
Show 3-colorable graph with hamiltonian cycle is NP-Complete |
I was studying about Moore and Mealy machines but having hard time connecting with them because 1) they are different from typical normal machines.what is the need of "output" and 2) My text book doesn't cover it (Michael Sipser). What are the application for Moore and Mealy machines? I would like some resources. |
Resources on Moore and Mealy Machines |
|finite-automata| |
Consider a nondeterministic TM $M$ that takes as input another TM $M'$, a string $x$ and integer $k$. $M$ decides if there exists a string y s.t. $|y| \leq |x|^2$ and $M'(x, y)$ accepts in $k$ steps. Show that $M$ runs in exponential time.
I don't see why it is exponential time. $M$ guesses $y$ with length $|x|^2$, ... |
Proof that nondeterministic TM runs in exponential time |
|turing-machines|np|nondeterminism| |
Consider the parity function $MOD_2(x) = x_1 \oplus \cdots \oplus x_n$ for $x \in \mathbb{F}_2^n$. I am concerned about the degree bounds for a real polynomial $f$ which approximates $MOD_2$ well in the L1-norm i.e. $\sum_{x \in \mathbb{F}_2^n} |f(x)-MOD_2(x)|$ is as low as possible.
I am aware of the fact that any... |
Approximate the parity function in L1-norm |
|complexity-theory|approximation|boolean-complexity| |
Consider the parity function $MOD_2(x) = x_1 \oplus \cdots \oplus x_n$ for $x \in \mathbb{F}_2^n$. I am concerned about the degree bounds for a real polynomial $f$ which approximates $MOD_2$ well in the L1-norm i.e. $\sum_{x \in \mathbb{F}_2^n} |f(x)-MOD_2(x)|$ is as low as possible.
I am aware of the fact that any... |
Consider the parity function $MOD_2(x) = x_1 \oplus \cdots \oplus x_n$ for $x \in \mathbb{F}_2^n$. I am concerned about the degree bounds for a real polynomial $f$ which approximates $MOD_2$ well in the L1-norm i.e. $\sum_{x \in \mathbb{F}_2^n} |f(x)-MOD_2(x)|$ is as low as possible.
I am aware of the fact that any... |
Consider the parity function $MOD_2(x) = x_1 \oplus \cdots \oplus x_n$ for $x \in \mathbb{F}_2^n$. I am concerned about the degree bounds for a real polynomial $f$ which approximates $MOD_2$ well in the L1-norm i.e. $\frac{1}{2^n}\sum_{x \in \mathbb{F}_2^n} |f(x)-MOD_2(x)|$ is as low as possible.
I am aware of the ... |
The technical answer is that they imply each other. Since they are both true statements either implication evaluates to $T \to T$ which is a true statement. However, I know that you are really asking if you can prove MSTs have the cycle property only using the fact that they have cut property. The answer is no.
We d... |
Clearly, whether a formula is minimally unsatisfiable depends on the exact details of how it is formulated, so let me give a specific definition of Tseitin formulas. Given a graph $G=(V,E)$ and a vertex labelling $l\colon V\to\{0,1\}$, the CNF $T_{G,l}$ uses variables $\{p_e:e\in E\}$, and it includes clauses expressin... |
Clearly, whether a formula is minimally unsatisfiable depends on the exact details of how it is formulated, so let me give a specific definition of Tseitin formulas. Given a graph $G=(V,E)$ and a vertex labelling $l\colon V\to\{0,1\}$, the CNF $T_{G,l}$ uses variables $\{p_e:e\in E\}$, and it includes clauses expressin... |
null |
Assuming $k$ is represented in binary, it takes $\lg k$ bits to represent $k$. So an algorithm whose running time is $\Theta(k)$ runs in time that is exponential in the length of the input. "Exponential time" means "exponential in the length of the input". |
Moore and Mealy machines are often introduced as a tool for designing digital circuits.
Nice introductions can be found [here](https://www.allaboutcircuits.com/textbook/digital/chpt-11/finite-state-machines/) and [here](https://www.youtube.com/watch?v=O3If0Nr9to0). |
null |
A prominent and interesting application of transducers, among many others, is to define strategies in game theory. To illustrate this, let me show a few kinds of games and how their strategies differ.
First, *reachability games*. We are given a graph. One vertex is marked as the initial vertex, and some vertices are... |
null |
Consider the parity function $MOD_2(x) = x_1 \oplus \cdots \oplus x_n$ for $x \in \mathbb{F}_2^n$. I am concerned about the degree bounds for a real polynomial $f$ which approximates $MOD_2$ well in the L1-norm i.e. $\frac{1}{2^n}\sum_{x \in \mathbb{F}_2^n} |f(x)-MOD_2(x)|$ is as low as possible.
I am aware of the ... |
Consider the parity function $MOD_2(x) = x_1 \oplus \cdots \oplus x_n$ for $x \in \mathbb{F}_2^n$. I am concerned about the degree bounds for a real polynomial $f$ which approximates $MOD_2$ well in the L1-norm i.e. $\frac{1}{2^n}\sum_{x \in \mathbb{F}_2^n} |f(x)-MOD_2(x)|$ is as low as possible.
I am aware of the ... |
null |
{"Voters":[{"Id":163753,"DisplayName":"vyjtkbyykyhuk"}],"DeleteType":1} |
{"Voters":[{"Id":163753,"DisplayName":"vyjtkbyykyhuk"}]} |
So, this is a snippet of a C code:
for (i = 0; i < 20; i++) {
a[i] = rand() & 0xFF;
printf("a[%d]: %d\n", i, a[i]);
}
Now, imagine "i" is a local variable stored in the stack. How many times would "i" be called from the stack for each iteration? Is it:
>A. Once at the beginning of the lo... |
How Many Times Would The Assembler Load and Store i |
|assembly| |
The provided recurrence relation is as follows:
$$ T(n) = 8T\left(\frac{n - \sqrt{n}}{4}\right) + n^2 $$
The goal is to express the solution in terms of the asymptotic notation $\Theta$. Unfortunately, the Master's Theorem and Akra-Bazzi methods do not apply directly to this recurrence. Drawing a recursion tree w... |
How to Solve the Recurrence Relation $T(n) = 8T\left(\frac{n - \sqrt{n}}{4}\right) + n^2$ in terms of $\Theta$? |
|time-complexity|asymptotics|recurrence-relation|recursion| |
It’s asymptotically the same as the simple recurrence
$$T'(n)=8T'(n/4)+n^2,$$
which solves to $T'(n)\sim2n^2$ by any of the common methods (where as usual, I write $f(n)\sim g(n)$ for $\lim_{n\to\infty}f(n)/g(n)=1$).
On the one hand, $T'$ provides an upper bound on $T$. On the other hand, let us unwind the recurre... |
It’s asymptotically the same as the simple recurrence
$$T'(n)=8T'(n/4)+n^2,$$
which solves to $T'(n)\sim2n^2$ by any of the common methods (where as usual, I write $f(n)\sim g(n)$ for $\lim_{n\to\infty}f(n)/g(n)=1$).
On the one hand, $T'(n)\sim2n^2$ provides an upper bound on $T$. If you want to only estimate the ... |
I'm attempting to solve the recurrence relation:
$$ T(n) = 4T\left(\frac{n}{2}\right) + \frac{n}{\lg n} $$
in terms of its asymptotic behavior ($\Theta$), specifically using the first case of the Master's Theorem. We know that if $O(n^{2-\epsilon}) = \frac{n}{\lg n}$ is correct, then $T(n) = \Theta(n^2)$. However... |
Hwo to solve the Recurrence $ T(n) = 4T\left(\frac{n}{2}\right) + \frac{n}{\lg n} $ in terms of $\Theta$? |
|time-complexity|asymptotics|recurrence-relation|recursion| |
null |
Hwo to solve the recurrence $ T(n) = 4T\left(\frac{n}{2}\right) + \frac{n}{\lg n} $ in terms of $\Theta$? |
Given an unsorted array $A$ that contains $n$ elements of numbers. Also $A$ partitioned to $k$ lists $A_1,A_2,A_3,\dots,A_k$, each contains at most nearly $\frac{n}{k}$ elements. We choose exactly one elements from each $A_i$ so that difference between maximum and minimum element minimized.
I think this can't be don... |
Could this be done in $O(n\log k)$? |
|algorithms| |
A prominent and interesting application of transducers, among many others, is to define strategies in game theory. To illustrate this, let me show a few kinds of games and how their strategies differ.
First, *reachability games*. We are given a graph. One vertex is marked as the initial vertex, and some vertices are... |
Given an unsorted array $A$ that contains $n$ elements of numbers. Also $A$ partitioned to $k$ lists $A_1,A_2,A_3,\dots,A_k$, each contains at most nearly $\frac{n}{k}$ elements. We choose exactly one elements from each $A_i$ so that difference between maximum and minimum element minimized. Can this be done in $O(n\log... |
Choosing one element from each partition that minimize the difference between max and min |
Given an unsorted array $A$ that contains $n$ elements of numbers. Also $A$ partitioned to $k$ lists $A_1,A_2,A_3,\dots,A_k$, each contains at most nearly $\frac{n}{k}$ elements. We choose exactly one elements from each $A_i$ so that difference between maximum and minimum element minimized. Can this be done in $O(n\log... |
null |
If you want to see it explicitly here is the calculation:
$T(n)=4T\left(\frac{n}{2}\right) + \frac{n}{\log n}$ implies that the total number of recursions we do is $\log_2 n$. At the pass of the recursion $i$, we have $4^iT\left(\frac{n}{2^i}\right)$ plus all the other terms deriving by the non-recursive term given ... |
null |
null |
**This answer uses ARMv8 AArch64 Assembly (ARM64)**
.LC0:
.string "a[%d]: %d\n"
square:
stp x29, x30, [sp, -128]!
mov x29, sp
str w0, [sp, 28]
mov w0, 1 (A)
str w0, [sp, 124... |
You are given a binary pattern p. Problem is to construct a binary sequence of length n such that by sliding p over our sequence there is always at least one position where two 1s align (one in the pattern and other in our sequence).
Edit: I completely forgot to mention that the goal is to minimize the number of on... |
I guess that greedy approach should consider edges in weight decreasing order only.
>! Otherwise it may become much less optimal, getting approximation factor $c^{2n/3}$.
Then every edge $e_0$ of greedy matching may block up to two edges $e_1$ and $e_2$ of maximum weight matching. However since $e_0$ is taken by gr... |
I guess that greedy approach should consider edges in weight decreasing order only.
>! Otherwise it may become much less optimal, getting approximation factor as low as $c^{2n/3}$.
Then every edge $e_0$ of greedy matching may block up to two edges $e_1$ and $e_2$ of maximum weight matching. However since $e_0$ is t... |
What exactly do you mean by “load” and “store”? Accessing memory?
An optimising compiler will assign i to a register. Compilers for modern CPUs with many registers will expect that some set of registers are either not modified or restored by the callee, so i within a register will survive the calls to rand and print... |
You are given a binary pattern p. Problem is to construct a binary sequence of length n such that by sliding p over our sequence there is always at least one position where two 1s align (one in the pattern and other in our sequence).
Edit: I completely forgot to mention that the goal is to minimize the number of on... |
Clearly, whether a formula is minimally unsatisfiable depends on the exact details of how it is formulated, so let me give a specific definition of Tseitin formulas. Given a graph $G=(V,E)$ and a vertex labelling $l\colon V\to\{0,1\}$, the CNF $T_{G,l}$ uses variables $\{p_e:e\in E\}$, and it includes clauses expressin... |
You are given a binary pattern p. Problem is to construct a binary sequence of length n such that by sliding p over our sequence there is always at least one position where two 1s align (one in the pattern and other in our sequence).
The goal is to minimize the number of ones in the sequence.
For example let p =... |
null |
null |
How to solve the recurrence $ T(n) = 4T\left(\frac{n}{2}\right) + \frac{n}{\lg n} $ in terms of $\Theta$? |
null |
Note: I have read a [similar post][3], but my problem seems different from that.
# My problem:
I know that (see [this][1] and [this][2])
> 1. A subtype of another type should give stronger or the same specifications of the supertype.
> 2. Spec $A$ is stronger than spec $B$ iff the set of implementations that s... |
Is limiting the input type in subclasses legitimate (does it give a stronger or the same specification)? |
|type-theory|abstract-data-types| |
Note: I have read a [similar post][3], but my problem seems different from that. Read **my attempts to understand the problem** for why I believe they are different.
# My problem:
I know that (see [this][1] and [this][2])
> 1. A subtype of another type should give stronger or the same specifications of the super... |
null |
I'm not an expert on this, but with the way you have defined `EssayASummarizer`, I don't believe it is a subtype of `EssaySummarizer`. You have already explained why: the set of implementations that can instantiate `EssayASummarizer` is not a subset of the set of implementations that can instantiate `EssaySummarizer`.... |
Given an undirected graph $G$ and two vertices $s$ and $t$, i want to find a set of edges $E$ in $G$ such that every (simple) $s$-$t$-path contains at least 2 edges from $E$.\
Is this problem solvable in polynomial time? What if the paths should not contain 2, but $r$ edges in $E$?
I know that for $r=1$, this is eq... |
Finding a set of edges $E$ such that every $s$-$t$-path contains at least 2 edges from $E$ |
|algorithms|graphs|network-flow|path| |
To illustrate gnasher729’s answer, here is how the snippet was compiled by gcc. As you can see, the value of `i` is kept in register `rbx` and never written to memory (no space is even allocated to it on the stack). The only memory stores are to `a[i]` (which I made a global variable; I’m not sure that was the intent i... |
To illustrate gnasher729’s answer, here is how the snippet is compiled by gcc. As you can see, the value of `i` is kept in register `rbx` and never written to memory (no space is even allocated to it on the stack). The only memory stores are to `a[i]` (which I made a global variable; I’m not sure that was the intent in... |
This follows easily from [Parikh's theorem](http://en.wikipedia.org/wiki/Parikh's_theorem), but there is also a [relatively short proof](https://cs.stackexchange.com/a/118017/168575) using the [pumping lemma](https://en.wikipedia.org/wiki/Pumping_lemma_for_context-free_languages) (which is easier to prove than Parikh's... |
$(n - \sqrt n) / 4$ is slightly smaller than n/4, for example >= $n \cdot (3/16)$ if n >= 16. So you get a lower limit if you take $8T(n \cdot (3/16)) + n^2$
If n >= 64, then $n - \sqrt n >= n \cdot (7/8)$, and the larger n is, the closer that factor is to 1. You take $8T(n \cdot (7/32)) + n^2$ as a lower bound if n... |
I work in the fields of theoretical CS, formal verification, and symbolic AI. Here's my DBLP link to have a picture of my background: [DBLP][1]
Can you suggest me resources (good graduate-level textbooks) to learn modern machine learning in a principled way sufficient to get up and running to understand current rese... |
Textbooks to study machine learning as a TCS/FM/formal AI researcher |
|machine-learning|reference-request| |
Textbooks to study machine learning as a TCS/FM/symbolic AI researcher |
null |
**The info I am given** : block_ID, block_width, block_height as well as how the cuts between the rectangles are(horizontal or vertical); for example two rectangles can be joined by a horizontal cut or a vertical cut. **See below picture for greater clarity**(H symbolizes horizontal cut and likewise V for vertical cuts... |
Want to plot rectangles given their width,height and the cartesian origin (0,0) |
|data-structures|computational-geometry| |
[![enter image description here][1]][1]
**The info I am given** : block_ID, block_width, block_height as well as how the cuts between the rectangles are(horizontal or vertical); for example two rectangles can be joined by a horizontal cut or a vertical cut. **See above picture for greater clarity**(H symbolizes hori... |
Given a SAT instance such that:
1. Each clause is of length at most 4.
2. Negative literal occurs only in clauses of length=2.
3. Each length 2 clause has at most 1 negative literal.
Is this version of SAT NP-Complete? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.