instruction stringlengths 0 29.8k ⌀ |
|---|
Time complexity of T(n) = 1600T(n/4) + n! |
|time-complexity|factorial| |
I'm trying to find the time complexity of T(n) = 1600T(n/4) + n! . So far I have thought of changing n! to something usable by the master theorem. Stirling's approximation gives us the equation
$$\sqrt{2\pi n}\left(\frac{n}e\right)^n$$
I am confused on whether the value for d in the master theorem would become n... |
To apply the right case of the master theorem, in the relation
$$T(n) = aT\left(\frac{n}b\right)+f(n)$$
you have to compare $n^{\log_b a}$ and $f(n)$:
1. if $f(n) = \mathcal{O}(n^c)$ with $c<\log_b a$, then $T(n) = \Theta(n^{\log_b a})$;
2. if $f(n) = \Omega(n^c)$ with $c > \log_b a$, then $T(n) = \Theta(f(n))$;
... |
null |
I have a math problem I need to solve so I can complete an optimisation in a computer program. My initial approach was just to brute force all the possible permutations but it got out of hand quite quickly for larger sets. Here's the problem
Let's say you want to take `n` bets each with odds `k`. We want to optimize... |
Finding Optimal Configuration of Formula without trying every Permutation |
|optimization|search-algorithms|search-trees|permutations|search-problem| |
I have a math problem I need to solve so I can complete an optimisation in a computer program. My initial approach was just to brute force all the possible permutations but it got out of hand quite quickly for larger sets. Here's the problem
Let's say you want to take `n` bets each with odds `k`. We want to optimize... |
Notice that the equation $o = \min(a_1 x(a_1) - a_2 - a_3 - ..., a_2 x(a_2) - a_1 - a_3 - ..., ...)$ (I'm using $a_1 , a_2 , ...$ instead of $a, b, c, ...$) can be rewritten as $$o = \min(a_1 (x(a_1)+1) - \sum a_i, a_2 (x(a_2)+1) - \sum a_i, ...) = \min(a_1 (x(a_1)+1), a_2 (x(a_2)+1), ...) - \sum a_i$$ We will use $b_i... |
First, take a look at https://www.geeksforgeeks.org/length-of-longest-palindrome-substring/ This might answer your question completely.
This will give you $O(n^2)$ time and $O(n)$ space complexity.
Now here is another trick that I think will work. We already know to find the longest common subsequence given two... |
Notice that the equation $o = \min(a_1 x(a_1) - a_2 - a_3 - ..., a_2 x(a_2) - a_1 - a_3 - ..., ...)$ (I'm using $a_1 , a_2 , ...$ instead of $a, b, c, ...$) can be rewritten as $$o = \min(a_1 (x(a_1)+1) - \sum a_i, a_2 (x(a_2)+1) - \sum a_i, ...) = \min(a_1 (x(a_1)+1), a_2 (x(a_2)+1), ...) - \sum a_i$$ We will use $b_i... |
Now suppose there are $k$ sets in the optimal solution and let that be $OPT = \{O_1,...,O_k\}$
Here the sets in the family look like intervals of integers because they contain only consecutive numbers.
Let $I_1,...,I_n$ be the given sets where $I_i = \{j+1,...,j+k\}$. We define the left and right endpoints of an... |
{"Voters":[{"Id":156762,"DisplayName":"Sandra"}]} |
Notice that the equation $o = \min(a_1 x(a_1) - a_2 - a_3 - ..., a_2 x(a_2) - a_1 - a_3 - ..., ...)$ (I'm using $a_1 , a_2 , ...$ instead of $a, b, c, ...$) can be rewritten as $$o = \min(a_1 (x(a_1)+1) - \sum a_i, a_2 (x(a_2)+1) - \sum a_i, ...) = \min(a_1 (x(a_1)+1), a_2 (x(a_2)+1), ...) - \sum a_i$$ We will use $b_i... |
null |
I'm currently investigating the computational complexity of a modified one-dimensional Suguru puzzle. The general Suguru puzzles were recently proven to be NP-complete (see [here][1]). My investigation considers a modified one-dimensional Suguru puzzle played in a $1 \times N$ grid of cells. These cells are grouped int... |
Possibly Tractable Variation of Suguru Puzzles |
|time-complexity|np-complete|arrays|greedy-algorithms| |
|algorithms|time-complexity|np-complete|arrays|greedy-algorithms| |
This questions is about the work [A novel similarity-search method for mathematical content in LaTeX markup and its implementation](http://tkhost.github.io/opmes/thesis-ref.pdf).
The parser used by Wei Zhong is [LALR](https://en.wikipedia.org/wiki/LALR_parser).
Now, supose I have to parse a function $func(foo)=ba... |
Why is a LALR parser the correct choice for parsing mathematical content? (a question about Approach0) |
|parsers| |
null |
This questions is about the work [A novel similarity-search method for mathematical content in LaTeX markup and its implementation](http://tkhost.github.io/opmes/thesis-ref.pdf).
Mr. Wei Zhong uses [flex](https://en.wikipedia.org/wiki/Flex_(lexical_analyser_generator)) lexer generator.
Now, supose I find an expre... |
Why is flex the best choice for handling mathematical content? (a question about approach0) |
|parsers| |
The formula $((x_1 \lor x_2) \lor (x_3 \lor x_2)) \land (x_3 \lor x_4)$ is equivalent to $(x_1 \lor x_2 \lor x_3) \land (x_3 \lor x_4)$. Notice that the last formula contains the subformula $(x_1 \lor x_2 \lor x_3)$. If we can convert this formula to a 2-CNF formula, then we are done (we can construct an implication gr... |
null |
I was given an assignment in which I had multiple recurrence relations and I had to find their Big-oh time complexities. Nearly all of the recurrence relations were of the form as under:
>$$T(n)=aT(n/\alpha)+bT(\beta n/\alpha)+f(n)$$
So I tried to find the general Big-oh complexity, so that I could solve each on... |
Finding general time complexity for recurrence relation $T(n)=aT(n/\alpha)+bT(\beta n/\alpha)+f(n)$ |
|time-complexity|asymptotics|big-o-notation| |
What you are looking for are Point-to-Point Shortest Path Algorithms, which are often needed in finding the shortest paths in street networks. I am speculating here about you specific problem.
In this context the graphs are planar and have some sort of structure we can use.
The [A* algorithm][1] is the most promine... |
null |
You can solve this (for well-behaved $f$) using the [Akra–Bazzi theorem](https://en.wikipedia.org/wiki/Akra%E2%80%93Bazzi_method), a generalization of the master theorem. The answer will depend on the relation between the parameters $a,b,\alpha,\beta$ and the asymptotics of $f$. |
As [@Dmitry](https://cs.stackexchange.com/users/141796/dmitry) said [in a comment](https://cs.stackexchange.com/questions/157284/why-is-a-lalr-parser-the-correct-choice-for-parsing-mathematical-content-a-que#comment330839_157284), the input is partitioned into tokens by the lexical analyser (or "scanner"), normally gen... |
null |
{"Voters":[{"Id":4416,"DisplayName":"rici"}]} |
The lexer doesn't interpret anything. It just separates the input into tokens. It's up to the parser to decide what the syntactic rôle of π is in that input.
It's possible that the thesis discusses that question; I didn't read it from end to end. But as far as I can see, the thesis never claims that the parsing t... |
By [Cunningham's law][1], this is the best possible time complexity.
[1]: https://meta.wikimedia.org/wiki/Cunningham%27s_Law |
null |
As [@Dmitry](https://cs.stackexchange.com/users/141796/dmitry) said [in a comment](https://cs.stackexchange.com/questions/157284/why-is-a-lalr-parser-the-correct-choice-for-parsing-mathematical-content-a-que#comment330839_157284), the input is partitioned into tokens by the lexical analyser (or "scanner"), normally gen... |
{"Voters":[{"Id":4416,"DisplayName":"rici"}]} |
The Java type system is strong. There are simply some errors that could, in theory, be reported at compile time that the Java Language Specification does not explicitly prohibit, and thus they are reported at run-time instead of compile time.
This really isn't that complicated, and it's all spelled out in the Java L... |
As [@Dmitry](https://cs.stackexchange.com/users/141796/dmitry) said [in a comment](https://cs.stackexchange.com/questions/157284/why-is-a-lalr-parser-the-correct-choice-for-parsing-mathematical-content-a-que#comment330839_157284), the input is partitioned into tokens by the lexical analyser (or "scanner"), normally gen... |
As [@Dmitry](https://cs.stackexchange.com/users/141796/dmitry) said [in a comment](https://cs.stackexchange.com/questions/157284/why-is-a-lalr-parser-the-correct-choice-for-parsing-mathematical-content-a-que#comment330839_157284), the input is partitioned into tokens by the lexical analyser (or "scanner"), normally gen... |
Given an arbitrary (potentially ambiguous) context free grammar $G: \mathbb{G}$, and string $\alpha: \Sigma^\ast$, is there a decision procedure that returns whether appending and/or prepending symbols can alter the parse forest of $\alpha$? In other words, we want a function $F: (\mathbb{G} \times \Sigma^\ast) \righta... |
Determining when a substring has a unique parse forest |
|formal-languages|formal-grammars| |
|formal-languages|context-free|formal-grammars|parsers| |
So I have an undirected graph G(V, E). We may assume there is always at least one path between any two vertices. I want to efficiently check if there are at least 2 different paths between *x* and *y* that have no vertices in common. Equivalent problem would be to find if all paths between *x* and *y* go through a vert... |
Find if there is more than one path between two vertices such that no vertices are used more than once |
|graphs| |
So I have an undirected graph G(V, E). We may assume there is always at least one path between any two vertices. I want to efficiently check if there are at least 2 different paths between *x* and *y* that have no vertices in common. (I'm pretty sure that) Equivalent problem would be to find if all paths between *x* an... |
The formal definition of complexity of an algorithm is the runtime in terms of the length of the input. Meaning, suppose you have a number with size n, to represent the number n you need $log_2(n)$. Thus, the actual time complexity is the runtime relative to $log_2(n)$ bits and not n.
For instance, when computing th... |
Good question. You are right, the running time of an algorithm is defined in terms of the total number of operations.
The reason is because in all standard comparison-based algorithms, the total running time $T$ is always at most some constant times the number of comparisons $P$. In other words, there is some cons... |
|complexity-theory|terminology|complexity-classes|p-vs-np| |
|theory|programming-contest| |
|algorithms|mathematical-programming|algorithm-design| |
null |
You're asking about how to find a pair of vertex-disjoint paths from $x$ to $y$. You can use [Suurballe's algorithm](https://en.wikipedia.org/wiki/Suurballe%27s_algorithm) to solve this. See the "variations" part of that page for how to adapt it to find vertex-disjoint paths. Suurballe's algorithm works with directe... |
null |
As [@Dmitry](https://cs.stackexchange.com/users/141796/dmitry) said [in a comment](https://cs.stackexchange.com/questions/157284/why-is-a-lalr-parser-the-correct-choice-for-parsing-mathematical-content-a-que#comment330839_157284), the input is partitioned into tokens by the lexical analyser (or "scanner"), normally gen... |
As [@Dmitry](https://cs.stackexchange.com/users/141796/dmitry) said [in a comment](https://cs.stackexchange.com/questions/157284/why-is-a-lalr-parser-the-correct-choice-for-parsing-mathematical-content-a-que#comment330839_157284), the input is partitioned into tokens by the lexical analyser (or "scanner"), normally gen... |
What is the smallest NFA that could be design for a^n where n!=1003?
I have been racking my brain at this for a while but still can't reduce the number of states required from 1004. Here state(1003) will be a rejecting state and all the other previous state will be accepting state. A transition from state(1003) to s... |
What is the smallest NFA you can design for {a n : n ̸= 1003} |
|turing-machines|finite-automata|nondeterminism| |
Consider the set of the Myhill–Nerode equivalence classes.
For any $n \in \{0 \, \dots, 1003 \}$, the word $a^n$ is in it's own equivalence class since $a^{1003-n}$ is a distinguishing extension for $a^n$ and and any other word $w \neq a^n$.
Moreover, the words $a^n$ with $n \ge 1004$ all belong to the same equi... |
While working on a math problem the following tree structure came up:
```txt
o
\
o
/
o
/ \
o o
/ \ /
```
It is a binary tree with the following constraints:
- all nodes except the root have a left child
- all left-child nodes have a right child
- none of the right-child... |
Is there a name for this kind of binary tree? |
|data-structures|trees|binary-trees| |
{"Voters":[{"Id":6759,"DisplayName":"Steven"}]} |
For each $i \in \{0, \dots, 1003\}$ let $p_i = (a^i, a^{1023-i})$.
We can then invoke Theorem $1$ in the paper [A lower bound technique for the size of nondeterministic finite automata][1] choosing $P = \{p_1, \dots, p_{1003}\}$ to conclude that a lower bound on the number of states of any NFA is $1004$.
It is ea... |
{"Voters":[{"Id":6759,"DisplayName":"Steven"}]} |
I am looking for an efficient CNF encoding of the following situation: I have sets of boolean literals $A = \{ a_1, \ldots, a_m \}$, $B = \{ b_1,\ldots, b_n \}$ and subsets $B_1, \ldots, B_m$, where for all $i$ we have $B_i \subseteq B$ and $|B_i|\le 10$. I would like to encode the constraints
$$ a_i \to \bigwedge_{b ... |
Encoding "all-except" constraints in CNF |
|reference-request|satisfiability|constraint-satisfaction|modelling|constraint-programming| |
Just a quick association to your tree structures and Fibonacci numbers.
The numbering scheme and hence the tree structure seems related to the concept of *exponentiation by squaring*. The power of a number (or matrix) can be recursively computed as follows.
- $A^{2n} = A^n * A^n $
- $A^{2n+1} = A * A^{2n} $
I... |
null |
I'm currently investigating the computational complexity of a modified one-dimensional Suguru puzzle. The general Suguru puzzles were recently proven to be NP-complete (see [here][1]). My investigation considers a modified one-dimensional Suguru puzzle played in a $1 \times N$ grid of cells. These cells are grouped int... |
There is a simple linear-time algorithm that determines whether it is possible or find a possible way.
#### The algorithm for the decision problem
The idea is to collect the choices at the rightmost cell of each region, scanning regions from left to right.
1. Check whether the initial configuration is valid, i... |
If $L$ is a decidable language, $M$ is a Turing machine that determines $L$. For $\forall s \in L$, M accepts, and for $\forall s \in \overline{L}$, M rejects
However, my question is that
If $L$ is a recognizable undecidable language and $M$ is a Turing machine that recognizes $L$, for $\forall s \in L$, M accepts ... |
L is a recognizable undecidable language ,M is a Turing machine that recognizes L, does M reject or infinitely loop for s belonging to L-complement? |
|turing-machines|decidability|turing-recognizable| |
There is a simple linear-time algorithm that determines whether it is possible or find a possible way.
#### The algorithm for the decision problem
The idea is to collect the choices at the rightmost cell of each region, scanning regions from the leftmost region, i.e. region $1$ to the rightmost region, i.e. regio... |
Let $L$ be an arbitrary language in $\Sigma_3$. Thus it can be written that $x \in L \Leftrightarrow \exists y^{p(|x|)} \forall z^{p(|x|)} \exists w^{p(|x|)} \langle x,y,z,w \rangle \in B$ where $p(\cdot)$ is some polynomial function and $B$ is some language in $P$.
While giving a reduction from $L$ to $\Sigma_3$-SA... |
Are the indices of variables in the formula variable? |
|complexity-theory|reductions| |
|complexity-theory|reductions|satisfiability|polynomial-time-reductions| |
Let $L$ be an arbitrary language in $\Sigma_3$. Thus it can be written that $x \in L \Leftrightarrow \exists y^{p(|x|)} \forall z^{p(|x|)} \exists w^{p(|x|)} \langle x,y,z,w \rangle \in B$ where $p(\cdot)$ is some polynomial function and $B$ is some language in $P$.
While giving a reduction from $L$ to $\Sigma_3$-SA... |
If $L$ is recognizable but not decidable, and $M$ is a Turing machine that recognizes $L$ then, for each $s \in \overline{L}$, $M(s)$ either rejects or it does not halt.
The behaviour of $M$ can differ for different choices of $s \in \overline{L}$, so it is definitely possible that there are $s_1, s_2 \in \overline... |
There is a simple linear-time algorithm that determines whether it is possible or find a possible way.
#### The algorithm for the decision problem
The idea is to collect the choices at the rightmost cell of each region, scanning regions from the leftmost region, i.e. region $1$ to the rightmost region, i.e. regio... |
null |
For each $i \in \{0, \dots, 1003\}$ let $p_i = (a^i, a^{1003-i})$.
We can then invoke Theorem $1$ in the paper [A lower bound technique for the size of nondeterministic finite automata][1] choosing $P = \{p_1, \dots, p_{1003}\}$ to conclude that a lower bound on the number of states of any NFA is $1004$.
It is ea... |
Consider array $A=\{a_1,a_2,...,a_n}$ such that $a_i$s are positive integers. Moreover, we have $k$ binary tuples, each with length $n$. In each iteration, we choose one of those tuples, and decrease it from the array. For example, if $A=\{5,7,4,2\}$ and we decrease $(1,0,0,1)$ from it, it will become $\{4,7,4,1\}$. We... |
Is this sorting problem NP-complete? |
|np-complete|reductions|sorting|np-hard|polynomial-time-reductions| |
Consider array $A={a_1,a_2,...,a_n}$ such that $a_i$s are positive integers. Moreover, we have $k$ binary tuples, each with length $n$. In each iteration, we choose one of those tuples, and decrease it from the array. For example, if $A=\{5,7,4,2\}$ and we decrease $(1,0,0,1)$ from it, it will become $\{4,7,4,1\}$. We ... |
Consider array $A=[a_1,a_2,...,a_n]$ such that $a_i$s are positive integers. Moreover, we have $k$ binary tuples, each with length $n$. In each iteration, we choose one of those tuples, and decrease it from the array. For example, if $A=[5,7,4,2]$ and we decrease $(1,0,0,1)$ from it, it will become $[4,7,4,1]$. We cann... |
When using the Baum-Welch algorithm to train a hidden markov model you normally repeat it on some observed sequence iteratively until your values converge.
If you have multiple observed sequences, Wikipedia tells you to run the update on all sequences in parallel and then combine them into a new model and then apply... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.