instruction
stringlengths
0
29.8k
⌀
null
Consider this context-free grammar: $$G:\\\;\; S\to aSbb|aaSbbb|\lambda$$ Is the string $a^{2020} b^{4020}\in L(G)$? I try to derive such a string but I can't, how it possible?
How it possible given string belong to given grammar
|formal-languages|context-free|
null
This is possible, provided there is a solution in nonnegative integers to the following pair of equations. $$ \left\{ \begin{array}{rcrc@{\qquad}l} x & + & 2y & = & 2020 \\ 2x & + & 3y & = & 4020 \end{array} \right. $$
{"Voters":[{"Id":167063,"DisplayName":"Kevin Tsou"}],"DeleteType":1}
{"Voters":[{"Id":167063,"DisplayName":"Kevin Tsou"}]}
null
I wrote code for the Regular Simplex (RSM) and the Irregular Simplex (Nelder-Mead Method (N-MM)) in Visual Studio in C++. For given functions (quadratic (QF), Rosenbrock with alpha = 1 (RF1), Rosenbrock with alpha = 12 (RF12)), starting points ({-1, -1}, {2, 2}), accuracies (1e- 2, 1e-5) received the number of iteratio...
The problem of finding a local minimum of a function
|optimization|program-optimization|
In the incomplete [GeeksForGeeks question #8](https://www.geeksforgeeks.org/practice-questions-time-complexity-analysis/), it is only correct when $k > 1, k \in \mathbb{Z}$. The code is equivalent to `for(int i=0;i<n;i=1+i*k)`. We can work out the first few iterations and see: Iteration #$1$: $i = 1 + 0k = 1$ Ite...
I am very interested in the following questions, which sprang out from the topological study of loops in surfaces and their intersection numbers. Consider, over a finite set of boolean variables $X$, a [Boolean system in CNF][1] (conjunctive normal form) whose clauses only contain non-negated literals. Assume the...
Monotone boolean satisfiability problem : finding minimal solutions
null
null
In the incomplete [GeeksForGeeks question #8](https://www.geeksforgeeks.org/practice-questions-time-complexity-analysis/), it is only correct when $k > 1, k \in \mathbb{Z}$. The code is equivalent to `for(int i=0;i<n;i=1+i*k)`. We can work out the first few iterations and see: Iteration #$1$: $i = 1 + 0k = 1$ Ite...
The complement of the language $L = \{a^nb^n : n \in \mathbb{N}\}$ should actually be linear, if I'm not mistaken. Take some string $x \notin L$ over the alphabet $\Sigma = \{a, b\}$, since $L \subseteq a^*b^*$ one of three cases must be true: - $x \notin a^*b^*$, or - $x = a^nb^m \in a^*b^*$ and $n > m$, or - $...
The complement of the language $L = \{a^nb^n : n \in \mathbb{N}\}$ should actually be linear, if I'm not mistaken. Take some string $x \notin L$ over the alphabet $\Sigma = \{a, b\}$, since $L \subseteq a^*b^*$ one of three cases must be true: - $x \notin a^*b^*$, or - $x = a^nb^m \in a^*b^*$ and $n > m$, or - $...
The complement of the language $L = \{a^nb^n : n \in \mathbb{N}\}$ should actually be linear, if I'm not mistaken. Take some string $x \notin L$ over the alphabet $\Sigma = \{a, b\}$, since $L \subseteq a^*b^*$ one of three cases must be true: - $x \notin a^*b^*$, or - $x = a^nb^m \in a^*b^*$ and $n > m$, or - $...
You can't, because the length of the shortest path between $u$ and $v$ is not known. The purpose of the Bellman-Ford algorithm is to compute such lengths, so you can't assume they are already known.
I am very interested in the following questions, which sprang out from the topological study of loops in surfaces and their intersection numbers. Consider, over a finite set of boolean variables $X$, a [Boolean formula in CNF][1] (conjunctive normal form) whose clauses only contain non-negated literals. Assume th...
null
null
null
Is the time complexity of `for(int i=0;i<n;i++){i*=k;}` $O(\log_k n)$? The problem is number 8 from GeeksForGeeks: <br> https://www.geeksforgeeks.org/practice-questions-time-complexity-analysis/ I trace the program by hand and got stuck. I could not prove that the answer is $O(\log_k n)$. I made a mistake somewh...
Is the time complexity of a loop that simultaneously increments and multiplies $O(\log_k n)$ when $k = 1$?
|time-complexity|asymptotics|proof-techniques|
null
null
**tl;dr** As Lamport writes at the top of page 561 of [Time, Clocks, and the Ordering of Events in a Distributed System](https://doi.org/10.1145%2F359545.359563): > To break ties, we use any arbitrary total ordering $\prec$ of the processes. To elaborate, ties are indeed possible and already anticipated by Lamp...
Let's address your questions/confusions in order: 1. > I don't see the authors working on the former equation, only the latter. That's because $x$ doesn't matter: - it does not occur in the postcondition ($v \leq 1$) investigated here - it does not occur in the RHS of the equation for $v$ 2. > Why did the ...
I was referring to the textbook Artificial Intelligence: A modern approach 3rd by Stuart Russell and Peter Norvig. what to prove about the general "graph search": (Here I assume "within a factor of b" means multiplier $b$ instead of [addition $\pm b$][1] based on the complexity context. So if time complexity is $O(b...
How is the best way to go about proving that a greedy algorithm is optimal, inductive vs contradiction, are there parts in the proof that are key to include. I did not feel that the lesson I was given adequately covered how to start a greedy proof, any advise on a general way to go about proving greedy algorithms woul...
Proving Optimal Greedy Algorithms
|algorithms|proof-techniques|greedy-algorithms|correctness-proof|
null
{"OriginalQuestionIds":[59964],"Voters":[{"Id":755,"DisplayName":"D.W.","BindingReason":{"GoldTagBadge":"algorithms"}}]}
There's not enough information here to answer the question, but I can prove a pretty good guess based on how tokenizers are typically implemented. Generally the tokenizer will run through the list of patterns, trying each one I sequence. If one of them matches it takes the longest possible match as a token, then star...
null
I've implemented a ranking system (based on a score), using a Map<Player,Score> and an improved BST<Score, Set<Player>>. So now I can have "rank of a player" in O(log(n)), "top xxx players", insert/update/remove in O(log(n)) Now I want to improve by data structure to add a "best rank". So when a player score is up...
Improving a ranking system with "best rank"
|binary-trees|search-trees|rank|
Suppose I have a function $f: \mathbb{R}^n\rightarrow\mathbb{R}$. All I know about the function is, I have a set of pairs of vectors ($\vec{v}_a$, $\vec{v}_b$) for which I know which one is greater (i.e. I know that $f(\vec{v}_a)>f(\vec{v}_b)$). I want to find the minimum of the function (or at least a good approximati...
Find minimum of a function only knowing the ordering of a set of input points
|optimization|gradient-descent|topological-ordering|
null
I have a problem where I need to connect branches of multiple trees with edges such that every start node is connected to every other start node. Each tree can branch at a second node into 1-3 branches, with the count of branches always being even. I've implemented a solution, but it's not very readable or maintainable...
Efficient algorithm for connecting branches of multiple trees with edges to ensure full connectivity
|graphs|
I'm studying heuristics for a course in my Master's. Our professor has told us that in order to point to a higher grade in the exam, we should check if our algorithm hits a stagnation points and that we have not seen any clear improvements to the optimum we have found. He asked it for some algorithms, especially the Si...
A stagnation check for heuristics, especially simulated annealing?
|heuristics|simulated-annealing|
You can't. The function could be anything. For example, consider $$f(x) = \begin{cases} g(x) &\text{if }x \ne \alpha\\ -10^{100} &\text{if } x = \alpha \end{cases}$$ where $\alpha \in \mathbb{R}^n$ is some obscure point (maybe very far from the origin). Then any reasonable algorithm might never evaluate $f$...
I've implemented a ranking system (based on a score), using a Map<Player,Score> and an improved BST<Score, Set<Player>>. So now I can have "rank of a player" in O(log(n)), "top xxx players", insert/update/remove in O(log(n)) Now I want to improve by data structure to remember the "best rank" of each player. So whe...
|data-structures|binary-trees|search-trees|rank|
Suppose $L=\{ww^r:w\in\Sigma^*\}$. Already, we know that we can draw a PDA for $L$ such that accept each $w\in L$ with space complexity at least $|w|$. My question is how is it possible to draw a PDA that accepts or rejects $w$ with space complexity $\frac{w}{C}$ for some constant $C$? Any help or hint will be appre...
Accept $L=\{ww^r:w\in\Sigma^*\}$ in less that $|w|$ storage
|formal-languages|context-free|
null
It is (obviously) possible if $|\Sigma| = 1$ or $C = 1$. It is also possible for $|\Sigma| > 1$ and $C>1$. The idea is that you can use a bigger stack alphabet to encode multiple letters at once. For example, if $\Sigma = \{a, b\}$, the following PDA recognizes $L$, and the stack is at most $\frac{|w|}2$ for an i...
null
In most US universities, undergraduate students must satisfy the requirements of a degree program in order to graduate. The general rules are: - The university has a minimum number of total credits needed, and a series of subject-based baskets (e.g. sciences, humanities, writing, etc) with their own minimum credit ...
algorithm to categorize courses into academic degree requirements?
|algorithms|classification|packing|
You can't. The function could be anything. For example, consider $$f(x) = \begin{cases} g(x) &\text{if }x \ne \alpha\\ -10^{100} &\text{if } x = \alpha \end{cases}$$ where $\alpha \in \mathbb{R}^n$ is some obscure point (maybe very far from the origin). Then any reasonable algorithm might never evaluate $f$...
I'm assuming we're testing if a student satisfies the requirements for a specific degree, not whether it satisfies *any* degree. If so, we can immediately calculate the total number of credits, and whether all required courses have been satisfied with a single loop over the completed courses, using a hashset of requ...
null
null
It is (obviously) possible if $|\Sigma| = 1$ or $C = 1$. It is also possible for $|\Sigma| > 1$ and $C>1$. The idea is that you can use a bigger stack alphabet to encode multiple letters at once. For example, if $\Sigma = \{a, b\}$, the following PDA recognizes $L$, and the stack is at most $\frac{|w|}2$ for an i...
null
null
I was referring to the textbook Artificial Intelligence: A modern approach 3rd by Stuart Russell and Peter Norvig. what to prove about the general "graph search": (Here I assume "within a factor of b" means multiplier $b$ instead of [addition $\pm b$][1] based on the complexity context. So if time complexity is $O(b...
The answer by [@D.W.](https://cs.stackexchange.com/users/755/d-w) is correct that any search space will need *some* structure in order to make progress. However, I think it would be pessimistic to conclude that the No Free Lunch theorems apply; since they assume uniform sampling from the space of all functions, which i...
The answer by [@D.W.](https://cs.stackexchange.com/users/755/d-w) is correct that any search space will need *some* structure in order to make progress. However, I think it would be pessimistic to conclude that the No Free Lunch theorems apply; since they assume uniform sampling from the space of all functions, which i...
While reading an article devoted to the sparse self-attention, I came across a notation that was not very clear: $$ Attend(X, S) = \Big( a(x_i, S_i) \Big)_{i∈{\{1,...,n}\}} $$ What means $\Big( \space \space \Big)_{i∈{\{1,...,n}\}}$ ? It would be great to describe this in more detail. Link to the a...
Strange notation in the article about sparse self-attention
|machine-learning|natural-language-processing|
|machine-learning|linear-algebra|natural-language-processing|
Suppose $L$ is regular and we define $L'=\{x:\exists y\in L \wedge \text{ y be a subsequence of x}\}$. Could we conclude that $L'$ is regular or not? I think it's not regular because if $L=a^*b^*c^*$ then $L'$ could be $a^nb^nc^n$ so it can't be regular.
Is the $L'$ regular or not?
|formal-languages|regular-languages|
I think it's actually regular. Suppose $L$ is recognised by the DFA $A = (Q, \Sigma, \delta, q_0, F)$, define the NFA $A' = (Q, \Sigma, \delta', q_0, F)$ s.t. $$\delta'(q, a) = \{\delta(q, a)\} \cup \{q\}$$ for all $q \in Q, a \in \Sigma$. Intuitively, you can think of $A'$ as being the same as $A$ with the add...
The notation $$(x_i)_{i \in \{1,\dots,n\}}$$ is short-hand for $$(x_1,x_2,\dots,x_n).$$ Just two different ways to write the same thing. It is analogous to the relationship between $\sum_{i \in \{1,\dots,n\}} x_i$ and $x_1 + x_2 + \dots + x_n$. Two different ways to write the same thing.
{"OriginalQuestionIds":[77672],"Voters":[{"Id":755,"DisplayName":"D.W."}]}
I think it's actually regular. Suppose $L$ is recognised by the DFA $A = (Q, \Sigma, \delta, q_0, F)$, define the NFA $A' = (Q, \Sigma, \delta', q_0, F)$ s.t. $$\delta'(q, a) = \{\delta(q, a)\} \cup \{q\}$$ for all $q \in Q, a \in \Sigma$. Intuitively, you can think of $A'$ as being the same as $A$ with the add...
Suppose $L$ is regular and we define $L'=\{x:\exists y\in L \wedge \text{ y be a proper subsequence of x}\}$. Could we conclude that $L'$ is regular or not? I think it's not regular because if $L=a^*b^*c^*$ then $L'$ could be $a^nb^nc^n$ so it can't be regular.
``` public void m1(int n) { sum = 0; for (int i = n/2; i <= n; i++) { for (int j = 1; j <= n; j = 2 * j) { for (int k = 1; k <= n; k = k * 2) { sum++; } } } } ``` So, I know that the innermost loop and second loop are log(n) and the outer...
Big-O time complexity for this code snippet
|complexity-theory|time-complexity|asymptotics|java|
null
You are right, the two innermost loops perform $\Theta(\log n)$ iterations each, so we have a total of $\Theta(\log^2 n)$ iterations, which are repeated $\Theta(n)$ times in the outer loop, which implies that we have a total of $\Theta(n\log^2 n)$ iterations. You just have to multiply the number of iterations of ea...
I am implementing Earley parser and using algorithm from [Elizabeth Scott's paper "SPPF-Style Parsing From Earley Recognisers"][1] (section 4). Author says > A family of children of u will consist of one or two nodes. However algorithm as described in paper fails at following grammar: <S> ::= <A> | <B> ...
Can Shared Packed Parse Forest have more than 2 families?
|context-free|formal-grammars|parsers|
You are right, the two innermost loops perform $\Theta(\log n)$ iterations each, so we have a total of $\Theta(\log^2 n)$ iterations, which are repeated $\Theta(n)$ times in the outer loop, which implies that we have a total of $\Theta(n\log^2 n)$ iterations. You just have to multiply the number of iterations of ea...
i'm trying to make a game in which the player faces an infinite (finitely specified) series of enemies and has to specify a strategy that provably defeats all of them (ie defeats enemy n in finite time for all n). i'm intending to do it by having the player describe their strategy in a decidable language, which is then...
can a model of computation with infinitely many states be nontrivially decidable?
|decidability|infinity|