instruction
stringlengths
0
29.8k
⌀
I'm new to the complexity theory. I came across a complexity of $O\big(\frac{n}{m-n}\big)$, where both $n$ and $m$ are independent variables in my algorithm (assuming $m \geq n$). Since I haven't encountered the subtraction of two variables in the denominator before, I'm curious if it can be simplified further, per...
I'm new to the complexity theory. I came across a complexity of $O\big(\frac{n}{m-n}\big)$, where both $n$ and $m$ are independent variables in my algorithm (assuming $m \geq n$). Since I haven't encountered the subtraction of two variables in the denominator before, I'm curious if it can be simplified further, per...
I'm new to the complexity theory. I came across a complexity of $O\big(\frac{n}{m-n}\big)$, where both $n$ and $m$ are independent variables in my algorithm (assuming $m \geq n$). Since I haven't encountered the subtraction of two variables in the denominator before, I'm curious if it can be simplified further, per...
I'm new to the complexity theory. I came across a complexity of $O\big(\frac{n}{m-n}\big)$, where both $n$ and $m$ are independent variables in my algorithm (assuming $m \geq n$). Since I haven't encountered the subtraction of two variables in the denominator before, I'm curious if it can be simplified further, per...
I'm new to the complexity theory and have a basic question about the big-O notation that I encountered. I came across a complexity of $O\big(\frac{n}{m-n}\big)$, where both $n$ and $m$ are independent variables in my algorithm (assuming $m \geq n$). Since I haven't encountered the subtraction of two variables in 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$][2] based on the complexity context. So if time complexity is $O(b...
Prove the relation between space complexity and time complexity of the graph search which uses "the explored set"
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$][2] based on the complexity context. So if time complexity is $O(b...
You cannot make a better conclusion in the general case: - if $m$ is almost $n$ (not equal to $n$, otherwise $\frac{n}0$ is not defined), then it is $\mathcal{O}(n)$; - if $m$ is big enough compared to $n$ (meaning $m\geqslant (1 + \varepsilon) n$, with $\varepsilon > 0$ being a constant), then it is $\mathcal{O}(1)$...
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$][2] based on the complexity context. So if time complexity is $O(b...
Let All = {L ⊆ $∑^*$}. Prove that there isn't a complete language in All ( the set of all languages over the alphabet $∑^*$) **Attempt** Let $L$ and $\overline{L}$ be in All. And let's say there is a reduction between $L$ and $\overline{L}$. So, we can say that if there is a word w in $L$ it's also in $\overline{...
Let All = {L ⊆ $∑^*$}. Prove that there isn't a complete language in All. (A complete language L in All, would have to meet two conditions: 1.L ⊆ All 2. For any L' in All, there is a reduction L' ≤ L) **Attempt** Let $L$ and $\overline{L}$ be in All. And let's say there is a reduction between $L$ and $\overli...
null
Let All = {L ⊆ $∑^*$} (a collection of all languages above the alphabet $∑^*$). Prove that there isn't a complete language in All. (A complete language L in All, would have to meet two conditions: 1.L ⊆ $∑^*$ 2. For any L' in All, there is a reduction L' ≤ L) **Attempt** Let $L$ and $\overline{L}$ be in A...
Let All = {L ⊆ $∑^*$} (a collection of all languages above the alphabet $∑$). Prove that there isn't a complete language in All. (A complete language L in All, would have to meet two conditions: 1.L ⊆ $∑^*$ 2. For any L' in All, there is a reduction L' ≤ L) **Attempt** Let $L$ and $\overline{L}$ be in All...
Prove that there isn't a complete language over a given alphabet $\Sigma$. That is, there is no $C \subseteq \Sigma^*$ such that every $L \subseteq \Sigma^*$ is Turing-reducible to $C$. **Attempt:** Let $L$ be a language and let $\overline{L}$ be its complement. And let's say there is a reduction between $L$ and $...
Prove that there aren't any complete languages
null
Doesn't this follow by a counting argument? Fix a language $C\subseteq \Sigma^*$. On the one had, the number of languages that are Turing-reducible to $C$ is at most $\aleph_0$. Indeed, there are only countably many Turing machines $M_C$ with access to the oracle $C$ (see the answer of @Ariel [here][1]). On the other h...
Doesn't this follow by a counting argument? Fix a language $C\subseteq \Sigma^*$. On the one had, the number of languages that are Turing-reducible to $C$ is at most $\aleph_0$. Indeed, there are only countably many Turing machines $M_C$ with access to the oracle $C$ (see @Ariel's answer [here][1]). On the other hand, ...
Are languages generated from a statically typed language statically typed? So say, generating Python from C++. --- Issues: - The statically typed languaged must be well-typed so it should not necessarily contain ways to express dynamic types. - One may be able to emulate dynamic types by using some switc...
Are languages generated from a statically typed language statically typed?
|type-theory|type-checking|
null
I don't think your attempt works. $A \leq_T B$ doesn't imply $A \cap B \neq \emptyset$, take for example $$A = a^*, B = b^*.$$ We have $A \cap B = \emptyset$ as well as $A \leq_T B$. Also, it generally *is* the case that $L \leq_T \overline{L}$ if I'm not mistaken. Given $L \subseteq \Sigma^*$, define the oracle...
Pattern matching in programming languages as for example in [Racket][1] is some kind of parsing. Which level in the Chomsky hierarchy does this parsing technique have? Is it type-3 like regular expressions or type-2 or even lower? [1]: https://docs.racket-lang.org/reference/match.html
What is the Chomsky level of pattern matching?
|chomsky-hierarchy|
I'm seeking information about a specific sorting algorithm. This algorithm performs pairwise comparisons and distinguishes between three states: a > b: In this case, standard sorting logic proceeds (a precedes b). a < b: As usual, b precedes a. a = b: when elements are considered equal, both a and b are "fused...
Sorting with element merging
|algorithms|sorting|
I'm seeking information about a specific sorting algorithm. This algorithm performs pairwise comparisons and distinguishes between three states: a > b: In this case, standard sorting logic proceeds (b precedes a). a < b: As usual, a precedes b. a = b: when elements are considered equal, both a and b are "fused...
null
We can directly approach this problem using the recurrence tree method. Let us now denote $1-\alpha$ as $\beta$ for notational clarity. For any constant $l\ge2$ we have, $\alpha^l+\beta^l < 1$. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb...
The usage of "within" is a bit confusing, but I think it means the space complexity is never smaller than the time complexity divided by a factor of $b$. The space complexity of an algorithm is always smaller than its running time (since allocating/using $x$ space requires at least $c\cdot x$ time), so giving an upper ...
Suppose we have an approximation algorithm to some maximization problem, that returns a solution with value $(1-\epsilon)*OPT$. If the runtime of the algorithm is polynomial in the input size and $1/\epsilon$, then it is called an FPTAS. On the other hand, if the runtime is polynomial in the input size and $\log(1/\eps...
Is there a function between poly(log(n)) and poly(n)?
|time-complexity|approximation|
The hierarchy $$\text{regular languages $\subset$ deterministic context-free languages $\subset$ context-free languages $\subset$ context-sensitive languages $\subset$ recursively enumerable languages}$$ has an 'extra level' with respect to the Chomsky Hierarchy. ***Why is the Chomsky hierarchy taught...
Why the Chomsky Hierarchy?
|formal-languages|automata|chomsky-hierarchy|
I'm seeking information about a specific sorting algorithm. This algorithm performs pairwise comparisons and distinguishes between three states: a > b: In this case, standard sorting logic proceeds (b precedes a). a < b: As usual, a precedes b. a = b: when elements are considered equal, both a and b are "fused...
n / (m-n) is undefined for m = n. It is equal to +/- n if m = n +/- 1. But for example for m = 0 or m = 2n it is just +/- 1. You can’t really simplify this. For fixed n, you have a function that goes from 1 to n in a hyperbola, then from -n to -1 and getting still closer to 0, also in a hyperbola. Look out if n, m ...
For refresher, let's first remember ([Wikipedia](https://en.wikipedia.org/wiki/Conjunctive_normal_form)) that we can convert any Boolean expression into conjunctive normal form, which is defined as conjunction ("AND" $\land$) of one or more disjunctions ("OR" $\lor$) of one or more literals, and governed by six context...
For refresher, let's first remember ([Wikipedia](https://en.wikipedia.org/wiki/Conjunctive_normal_form)) that we can convert any Boolean expression into conjunctive normal form, which is defined as conjunction ("AND" $\land$) of one or more disjunctions ("OR" $\lor$) of one or more literals, and governed by six context...
The first example of a (nondeterministic) pushdown automata given in Linz' _An Introduction to Formal Languages and Automata_ is the following: **Example 7.2:** consider * $Q = \{q_0,q_1,q_2,q_3\}$, * $\Sigma = \{a,b\}$, * $\Gamma = \{0,1\}$, * $z = 0$, * $F = \{q_3\}$, with $q_0$ the initial state and * $\...
Not understanding example of a Pushdown Automata
|automata|pushdown-automata|
The reason it is not debated is because it is obvious, the reason that B-tree was invented, and subsequently B* tree is to reduce the frequency of rebalancing. Splitting and merging both involve rebalancing, therefore the more it is delayed the better. However, there is an exception to ordinary splitting rules when ...
1. For every two langueges A,B∈PSPACE, is there a language C∈PSPACE that A≤_P C ∧B≤_P C 2. For every two langueges C,A∈PSPACE, is there a language B∈PSPACE that A≤_P B ∧B≤_P C 3. For every two langueges C,B∈PSPACE, is there a language C∈PSPACE that A≤_P B ∧A≤_P C Can someone please help me determine which of th...
PSPACE - space complexity
|complexity-theory|computability|reductions|space-complexity|
Let $G = (V, E)$ be a flow network with a source $s$ and sink $t$. However, the constraints are a bit different: Conservation constraint is as usual. For each edge $e \in E$, we have that the flow $f$ maintains that $f(e) \geq c(e)$ when $c(e)$ is the capacity of $e$. The question asks to write an algorith...
Regarding 1: choose $C = \{0x \mid x \in A \} \cup \{1x \mid x\in B\}$. Regarding $2$: $B \le_P \emptyset \implies B=\emptyset$ however $\{\varepsilon\} \le_P B \implies B \neq \emptyset$. Regarding $3$: the statement is not well-formed.
1. For every two languages $A,B \in \mathsf{PSPACE}$, there is a language $C \in \mathsf{PSPACE}$ such that $A \le_P C \wedge B \le_P C$. 2. For every two languages $C,A \in \mathsf{PSPACE}$, there is a language $B \in \mathsf{PSPACE}$ such that $A \le_P B \wedge B \le_P C$. 3. For every two languages $C,B \in \math...
Let me ask my question very accurate, precise, and formal: A comparision tree (similar to the decision tree of a comparative sorting algorithm) is a full binary tree rooted at $s$ where each non-leaf node is labeled as an ordered pair $(x, y)$ such that for any vertex $w$, the path $sw$ contains no pair of vertices ...
How many comparative sorting algorithms are there?
|algorithms|data-structures|sorting|decision-tree|
Let me ask my question very accurate, precise, and formal: A comparision tree (similar to the decision tree of a comparative sorting algorithm) is a full binary tree rooted at $s$ where each non-leaf node is labeled as an ordered pair $(x, y)$ such that for any vertex $w$, the path $sw$ contains no pair of vertices ...
1. Correct: you can choose $C$ to be any $\text{PSPACE-complete}$ language. 2. The only known counter-examples to this claim are ones where $C$ or $A$ are trivial, and hence, sadly, a counter-example would be one of these boring edge cases. It is worth mentioning however that if $C$ and $A$ are assumed to be nontri...
1. Correct: you can choose $C$ to be any $\text{PSPACE-complete}$ language. 2. The only known counter-examples to this claim are ones where $C$ or $A$ are trivial, and hence, sadly, a counter-example would be one of these boring edge cases (I encourage you to check what happens if you consider $\emptyset$ or $\Sigm...
My question is about [LeetCode "137.Single Number II"][1]: >**137.Single Number II** > > Given an integer array nums where every element appears three times > except for one, which appears exactly once. Find the single element > and return it. > > You must implement a solution with a linear runtime complexity...
I think you can modify standard sorting algorithms to handle these goals. One simple approach: whenever you find two elements $a,b$ with $a=b$, delete one of the two elements. Another slightly more sophisticated approach: Construct a [union-find data structure](https://en.wikipedia.org/wiki/Disjoint-set_data_stru...
It is an arbitrary choice, based on a judgement call of the instructor about which levels of the hierarchy are most useful to focus on. I think one could make a good argument for focusing on the even simpler hierarchy $$\text{regular languages} \subset \text{context-free languages} \subset \text{recursively enume...
It depends on what types of patterns are supported. If it is only classical regular expressions, as in theoretical computer science, it is the regular languages. If it is Perl-compatible regular expressions (PCRE), then it is the context-sensitive languages; see https://cs.stackexchange.com/q/4839/755. See also ht...
the stack is kept track of by a so called "configuration". Imagine, that the configuration represents a complete description of your machine at a point in time. The transition function only needs to tell you, how the configuration might *change* during the computation. For a PDA $A = (Q, \Sigma, \Gamma, \delta, q_...
null
For the algorithm provided in answer to this [question](https://stackoverflow.com/questions/59903778/how-to-determine-length-of-array-in-olog-n-time-by-only-calling-ai), how would I go about proving the correctness of the algorithm? The referenced question is: “You are given an array $A$ of length $n$. Each valu...
Proof of correctness for Binary Search algorithm to find length of array for unknown length
|algorithms|correctness-proof|divide-and-conquer|binary-search|
{"Voters":[{"Id":150715,"DisplayName":"user19121278"}],"DeleteType":1}
{"Voters":[{"Id":150715,"DisplayName":"user19121278"}]}
I think you can modify standard sorting algorithms to handle these goals. One simple approach: whenever you find two elements $a,b$ with $a=b$, delete one of the two elements. Another slightly more sophisticated approach: Construct a [union-find data structure](https://en.wikipedia.org/wiki/Disjoint-set_data_stru...
null
I've invented an abstract structure to represent a comparison-based sorting algorithm, which I will call a *comparison tree* (similar to the decision tree of a comparative sorting algorithm). Specifically, a comparison tree is a full binary tree rooted at $s$ where each non-leaf node is labeled with an ordered pair $(...
The length of the array is $n_{min} \le n \le n_{max}$. Initially all you know is that $n_{min} = 0$ and $n_{max} = \inf$. Every step of the algorithm gives you more information. If $n_{min} = n_{max}$ then you know n. You need to examine the steps of the algorithm and show that it ends with that condition.
The length of the array is $n_{min} \le n \le n_{max}$. Initially all you know is that $n_{min} = 0$ and $n_{max} = \inf$. Every step of the algorithm gives you more information. If $n_{min} = n_{max}$ then you know n. You need to examine the steps of the algorithm and show that it ends with that condition. PS. You...
I have two groups *(GROUP1 and GROUP2)* of undirected weighted graphs - one having properties more similar to small world network and other relatively random. These are represented as adjacency matrices with 32 nodes and weights 0 to 1 representing connectivity strength among nodes. I am taking help of **small world...
Finding optimal threshold using small world network metrics to binarize 2 groups for comparison
|graphs|weighted-graphs|
Please tell me what is the correct formula for calculating the cost of an algorithm? I used this: number of calculated functions + 4 * number of calculated function gradients + 8 * number of calculated Hessian matrices of the function. I use this formula to calculate the cost of Newton's method of finding the minimum o...
The cost of an algorithm
|optimization|
{"Voters":[{"Id":150715,"DisplayName":"user19121278"}],"DeleteType":1}
Such a word contains atleast 2 consecutive $b$'s whenever a $b$ occurs in the middle of the word, or the word ends with a single $b$. We thus replace the language of all words made of some number of $a$s or $b$s, represented by $(a^\ast + b^\ast)^\ast$, with the language of words made of $a$s or atleast two $b$'s, whic...
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$][2] based on the complexity context. So if time complexity is $O(b...
Please tell me what is the correct formula for calculating the cost of an algorithm? I used this: number of calculated functions + 4 * number of calculated function gradients + 8 * number of calculated Hessian matrices of the function. I use this formula to calculate the cost of Newton's method of finding the minimum o...
null
To calculate the cost of an algorithm, measure its execution time in seconds. Then you either take the cost of a new computer, calculate for how many seconds it runs your algorithm during its life, adding cost for the space where it lives and electricity. Or you ask a cloud service provider what it costs to rent their ...
There are $n$ sticks of lengths $1$ to $n$. Upon permutating them randomly, calculate the average number of peaks when viewed from left. A peak is a stick such that all sticks to its left are shorter than it. For example, suppose there are $3$ sticks. The permutations and number of peaks are ``` 123 3 132 2 213 ...
Average number of peaks for permutations of n sticks
|probability-theory|permutations|counting|
There are $n$ sticks of lengths $1$ to $n$. Upon permutating them randomly, we may calculate the average number of peaks when viewed from left. A peak is a stick such that all sticks to its left are shorter than it. For example, suppose there are $3$ sticks. The permutations and numbers of peaks are ``` 123 3 132...
Growth of the average numbers of peaks for permutations of $n$ sticks
Our problem is similar to [this](https://cs.stackexchange.com/questions/93959/optimal-flow-in-a-network-with-non-constant-edges-weights), but it details various approaches we can make. The problem also was formulated [operation research](https://or.stackexchange.com/questions/11603/numerical-infeasibility-for-movi...
Optimization of value over network flow from start to end node with constant function multiplier edges tractability
|graphs|optimization|network-flow|
There are $n$ sticks of lengths $1$ to $n$. Upon permutating them randomly, we may calculate the average number of peaks when viewed from left. A peak is a stick such that all sticks to its left are shorter than it. For example, suppose there are $3$ sticks. The permutations and numbers of peaks are ``` 123 3 132...
Our problem is similar to [this](https://cs.stackexchange.com/questions/93959/optimal-flow-in-a-network-with-non-constant-edges-weights), but it details various approaches we can make. The problem also was formulated [operation research](https://or.stackexchange.com/questions/11603/numerical-infeasibility-for-movi...
null