instruction
stringlengths
0
29.8k
⌀
|algorithms|linear-algebra|
Suppose that you are given an algorithm A that finds the optimal solution to the shortest lattice vector problem (SVP) in time $t(n)$ I am trying to solve the <b>Small even set problem (SES)</b> using it: The input is a set $S$ of $m$ vectors $v_1,...,v_m$ with each $v_i$ in $\{0,1\}^d$. The goal is to find a non-e...
null
Use the Pumping Lemma to show $L_1 = \Sigma^*\setminus\{0^n1^n: n\geq 0\}$ is not regular, for $\Sigma=\{0,1\}$. I understand that $L_2 = \{0^n1^n: n\geq 0\}$ can be shown to be not regular using the Pumping Lemma by starting with a string in $L_2$ of length at least the pumping length, and try to pump it outside th...
Use the Pumping Lemma to show $\Sigma^*\setminus\{0^n1^n: n\geq 0\}$ is not regular
|computability|automata|finite-automata|pumping-lemma|computation-models|
I am reading Slavik's paper [A Tight Analysis of Greedy Set Cover](https://www.sciencedirect.com/science/article/pii/S0196677497908877). Specifically, Slavik considers the unweighted version of set cover where the ground set is ${U = \{1,\ldots,m\}}$ for arbitrarily large $m$. There is a collection of subsets ${S = \{...
Lower Bounding Set Cover's Approximation Ratio
|set-cover|
Question: Use the Pumping Lemma to show $L_1 = \Sigma^*\setminus\{0^n1^n: n\geq 0\}$ is not regular, for $\Sigma=\{0,1\}$. I understand that $L_2 = \{0^n1^n: n\geq 0\}$ can be shown to be not regular using the Pumping Lemma by starting with a string in $L_2$ of length at least the pumping length, and try to pump it ...
Question: Use the Pumping Lemma to show $L_1 = \Sigma^*\setminus\{0^n1^n: n\geq 0\}$ is not regular, for $\Sigma=\{0,1\}$. I understand that $L_2 = \{0^n1^n: n\geq 0\}$ can be shown to be not regular using the Pumping Lemma by starting with a string in $L_2$ of length at least the pumping length, and try to pump it ...
Question: Use the Pumping Lemma to show $L_1 = \Sigma^*\setminus\{0^n1^n: n\geq 0\}$ is not regular, for $\Sigma=\{0,1\}$. I understand that $L_2 = \{0^n1^n: n\geq 0\}$ can be shown to be not regular using the Pumping Lemma by starting with a string in $L_2$ of length at least the pumping length, and try to pump it ...
Question: Use the Pumping Lemma to show $L_1 = \Sigma^*\setminus\{0^n1^n: n\geq 0\}$ is not regular, for $\Sigma=\{0,1\}$. My thoughts: I understand that $L_2 = \{0^n1^n: n\geq 0\}$ can be shown to be not regular using the Pumping Lemma by starting with a string in $L_2$ of length at least the pumping length, and tr...
If $L_1$ was regular, then its [complement](https://cs.stackexchange.com/questions/63373/how-to-prove-that-the-complement-of-a-regular-language-is-always-regular), $L_2$, would be regular. This is a contradiction because you have shown that $L_2$ was not regular.
I am working through the book [Computer Systems: A Programmer's Perspective][1]. The authors explain that round-to-even rounding can be applied for values that are halfway between two possible results. For example, $10.11100_2$ would be rounded up to $11.00_2$ and $10.10100_2$ would be rounded down to $10.10_2$. ...
Floating-point rounding - bit patterns of values that are halfway between two possible results
|floating-point|rounding|
I have a problem where I have to find all the pairs of a list of People where the sum of their age is equal to a given number under time complexity less than O(N²) **Eg:** **Input:** {(Jhon, 10),(mary,20),(paul,10),(joseph,15)} Sum:30 **Expected results:** {(John, Mary), (Mary, ...
Is there any algorithm to find all unique pairs of People with age equal to a given number in less than O(n²)
I have a problem where I have to find all the pairs of a list of People where the sum of their age is equal to a given number under time complexity less than O(N²) **Eg:** **Input:** {(Jhon, 10),(mary,20),(paul,10),(joseph,15)} Sum:30 **Expected results:** {(John, Mary), (Mary, ...
There are cases where the output has size $\Omega(n^2)$, showing that the problem cannot be solved in time $o(n^2)$ in general. An example is the one you propose. E.g., the age of every person is $0$ and the target age is $0$.
Yes. You should read the lower bound as: there exists an instance with $m$ items such that $\frac{G}{\text{Opt}} \ge \log m - \log \log m - 0.31$.
Let us express any given binary number without a floating point in the following form $$\underbrace{XX\cdots X}_{i\text{ digits}}~Y~\underbrace{ZZ\cdots Z}_{j\text{ digits}}{}_2=x\times2^{j+1} + Y\times2^j+z $$ where $X$ denotes arbitrary bit values and $Y$ being the rightmost position to which we round. $x$ is the ...
It's provable that any $e$-deletion code is usable as an $e$-insertion code, but the proof is nonconstructive and doesn't necessarily give you an efficient decoding process would work. (There is a generally applicable brute-force approach – deleting each element individually to see which one gives you a valid codeword ...
Use the Pumping Lemma to show $\Sigma^*\setminus\{0^n1^n: n\geq 0\}$ is not regular (without using complement closure)
I think I have solved this! After reading more about it, it seems my hunch about trampolining -- see my comment from my previous answer -- is exactly what I want. So here's what we do: 1. Convert the recursive `foldr` into continuation-passing style. 2. Wrap each function evaluation into a thunk so no recursion act...
I was playing nandgame.com and noticed that the arithmetic unit of the ALU was doing both the add and subtract operation in parallel, but only asks for one operation per instruction. This to me seemed like it wasted resources, and I was interested in if this was a normal design-pattern in ALUs/CPUs. My question is, bro...
just given solution on this [post](https://stackoverflow.com/questions/73007397/sorting-large-arrays-of-big-numeric-sting) i had mention the time complexity to convert string to int is O(n), also verifying this [post](https://stackoverflow.com/questions/4483189/convert-string-to-number-vice-versa-complexity) now ...
time complexity to convert string to integer and vice a versa
|time-complexity|algorithm-analysis|strings|integers|
null
null
If I were to attempt to make a computing analogue of this question, it would be this: instead of relating 0 and 1 with 'false' and 'true', suppose we called them 'diverge' and 'halt'. Now by encoding all data as bits, we have a computational system where every (data) building block has been associated with definitely h...
**Are pure functions always computable functions?** **In computer programming, a [**Pure function**](https://en.wikipedia.org/wiki/Pure_function) is a function that has the following properties:**<br> (1) the function return values are identical for identical arguments (no variation with local static variables, no...
Are pure functions always computable functions?
|computability|functional-programming|
You can define the [Halting problem](https://en.wikipedia.org/wiki/Halting_problem) as a decision problem, where the function takes in a program and input, and determines whether the program will terminate or not. This is a pure function, but it's well-known that the Halting problem has no algorithm.
Agreed that worst case is $O(n^2)$, so you cannot find an algorithm in general that works better. If you modify the output to instead say a person followed by the corresponding people that would add up to the desired age, then you can do this in $O(n)$ with a modified 2-sum solution. Basically you would create ...
null
It depends what you mean by "pure function". You have to carefully define it. If "pure function" refers to computer code to compute some function, and if that code is guaranteed to always terminate, then yes, it computes a computable function. If "pure function" refers to computer code to compute some function, ...
It depends how you count. Theoretical analysis requires a model of the time it takes to do different operations, and depending on which model you choose, you get a different answer. One way to count running time is to assume that each basic operation takes one unit of time, and that you can multiply or add two inte...
Gandalf61 mentions [here][1] that there are opcodes that "load the next word into Register A", treat the bits at the next address defined by program counter as data and loads this data. I am interested in examples of computers and CPUs that have such as opcode. *Context: Learning basic computer architecture, and int...
The opcode "load the next word into Register A" mentioned by Gandalf61
|cpu|
I'm studying substitutions. A substitution is a set of mappings from variables to terms $\{a \rightarrow b; c \rightarrow d;...\}$. Given these substitutions: * $\sigma_1 := \{x \rightarrow y\}$ * $\sigma_2 := \{y \rightarrow x\}$ * $\sigma_3 := \sigma_1 \cup \sigma_2 $ And this term : $t := f(x, y)$ are fol...
Substitutions unions vs composition are not the same?
|first-order-logic|
It depends on whether the string representation is in base 10 or base 16. Conversion to/from base 10 -------------------------- Normally, when an integer is represented as a string, it is represented in base 10. Then here is the running time: It depends how you count. Theoretical analysis requires a model o...
Many/most architectures include this kind of instruction. It might be known as "load immediate" or "move" with an immediate/literal/constant value. See, e.g., https://en.wikipedia.org/wiki/Addressing_mode#Immediate/literal, https://en.wikipedia.org/wiki/Instruction_set_architecture#Data_handling_and_memory_operations...
null
null
null
null
**Are pure functions always computable functions?** **In computer programming, a [**Pure function**](https://en.wikipedia.org/wiki/Pure_function) is a function that has the following properties:**<br> (1) the function return values are identical for identical arguments (no variation with local static variables, no...
``` T(1)=1 Func_two (n,b) 1) if (n=0) 2) then return 1 3) else if (n=1) 4) then return b 5) else if (mod(n,3)==0) 6) then return Func_two(n/3,b) 7) else 8) return b*Func_two(n-1,b) ``` How do I calculate this? I see that $\mathcal{O}(\log(n))\le T(n) \le \mathcal{O}(n)$ because either we decrease...
complexity of a function that depends on n%3
|time-complexity|
It is very surprising to me that some combinatorial games such as generalized chess are EXPTIME complete. I have no idea why having a solver for a combinatorial game allows you to solve arbitrary exponential problems. The reason is that while I understand that such games can be solved in exponential time, they seem to ...
<!-- Definitions: (selected from Appendix B.4 of that textbook). --> The meanings of path, simple path, cycle, simple cycle are defined in Appendix B.4 of that textbook. ------ Claim: Let edge $u$ lie on simple cycle $\mathcal C_u$. Let edge $v$ lie on simple cycle $\mathcal C_v$. $\mathcal C_u$ and $\mathcal ...
Write $n$ in the ternary base. If the lowest order digit (trit) is a $1$ or a $2$, $T$ is called once or twice and $n$ becomes a multiple of $3$. Then the last digit (now a zero) is dropped. Hence, the total number of calls equals the sum of the trits of $n$ plus the number of trits. E.g. $n=43_d=1121_t\to1+1+2...
Write $n$ in the ternary base. If the lowest order digit (trit) is a $1$ or a $2$, $T$ is called once or twice and $n$ becomes a multiple of $3$. Then the last digit (now a zero) is dropped. Hence, the total number of calls equals the sum of the trits of $n$ plus the number of trits. E.g. $n=43_d=1121_t\to1+1+2...
Write $n$ in the ternary base. If the lowest order digit (trit) is a $1$ or a $2$, $T$ is called once or twice and $n$ becomes a multiple of $3$. Then the last digit (now a zero) is dropped. Hence, the total number of calls equals the sum of the trits of $n$ plus the number of trits. E.g. $n=43_d=1121_t\to1+1+2...
It depends on whether the string representation is in base 10 or base 16. Conversion to/from base 10 -------------------------- Normally, when an integer is represented as a string, it is represented in base 10. Then here is the running time: It depends how you count. Theoretical analysis requires a model o...
Use the Pumping Lemma to show $\Sigma^*\setminus\{0^n1^n: n\geq 0\}$ is not regular
Question: Use the Pumping Lemma to show $L_1 = \Sigma^*\setminus\{0^n1^n: n\geq 0\}$ is not regular, for $\Sigma=\{0,1\}$ (without using the complement closure property). My thoughts: I understand that $L_2 = \{0^n1^n: n\geq 0\}$ can be shown to be not regular using the Pumping Lemma by starting with a string in $L_...
Use the Pumping Lemma to show $\Sigma^*\setminus\{0^n1^n: n\geq 0\}$ is not regular (without using complement closure)
|computability|automata|finite-automata|pumping-lemma|computation-models|
Suppose towards a contradiction that $L_1$ is regular and let $p$ be its pumping length. Since $0^{p}1^{p+p!} \in L$ there must be some $1 \le k \le p$ such that $0^{p+ik} 1^{p + p!} \in L_1$ for every integer $i \ge -1$. Choosing $i=\frac{p!}{k}$ (this is an integer since $k$ is a factor of $p!$) yields the foll...
null
Without more a priori information on the distribution, **no algorithm can work**. Because you can never be sure if there is a larger $n$ than those already tried.
Without more a priori information on the distribution, **no algorithm can work**. Because you can never be sure if there is a larger $n$ than those already tried. ---------- The best (?) you could do is an exhaustive search: this guarantees that *you will someday* find the maximum $n$, though you will not know wh...
**Question**: prove that the grammar $G = (\{S\}, \{(,)\}, R, S)$ where $R$ consists of three rules: $S \rightarrow (S)~|~SS~|~\epsilon$ generates precisely all well-balanced parentheses. I found a [source](http://cse.iitkgp.ac.in/~abhij/course/theory/FLAT/Spring21/scribes/CFG-balanced.pdf) where it used induc...
Prove that the grammar $S\rightarrow (S)|SS|\epsilon$ generates precisely all well-balances parentheses
|algorithms|computability|context-free|computation-models|
**Question**: prove that the grammar $G = (\{S\}, \{(,)\}, R, S)$ where $R$ consists of three rules: $S \rightarrow (S)~|~SS~|~\epsilon$ generates precisely all well-balanced parentheses. I found a [source](http://cse.iitkgp.ac.in/~abhij/course/theory/FLAT/Spring21/scribes/CFG-balanced.pdf) where it used induc...
Assume `S` is the start symbol. Assume `1` and `0` are terminal symbols. Assume all other symbols are non-terminal. **Given set of (non-trivial) grammar rules,** **is it always possible to order them, such that,** **all the symbols on the left:** - **will be contained on the right in a previous rule** - **o...
Is it always possible to order grammar rules so that all the symbols on the left will be contained on the right in a previous rule?
|formal-grammars|
***Disclaimer 1: I am a beginner in this domain and I am self-learning these concepts. Please take this in consideration when reading my question.*** ***Disclaimer 2: All corrections to this question are highly encouraged. All self-learning PDF books etc. that helped you better understand these particular concepts a...
What complexity class is this?
|algorithms|complexity-theory|formal-languages|turing-machines|finite-automata|
I understand that in Heaps we add them from left to right. I understand how to add and delete. But why is it from left to right, is there something that prevents it from being right to left or something like that. My intuition tells me that it has something to do with the index.
Why are nodes added from left to right in last level in a Heap?
|algorithms|trees|heaps|
**Question**: prove that the grammar $G = (\{S\}, \{(,)\}, R, S)$ where $R$ consists of three rules: $S \rightarrow (S)~|~SS~|~\epsilon$ generates precisely all well-balanced parentheses. I found a [source](http://cse.iitkgp.ac.in/~abhij/course/theory/FLAT/Spring21/scribes/CFG-balanced.pdf) where it used induc...
**Question**: prove that the grammar $G = (\{S\}, \{(,)\}, R, S)$ where $R$ consists of three rules: $S \rightarrow (S)~|~SS~|~\epsilon$ generates precisely all well-balanced parentheses. I found a [source](http://cse.iitkgp.ac.in/~abhij/course/theory/FLAT/Spring21/scribes/CFG-balanced.pdf) where it used induc...
in a single board computer built around a 8085 processor, like in the old arcade/pinball games - what is the “role” of the EPROMs - am i correct, that they contain the code that the microprocessor runs..? i am most wondering if they are only active at turn-on, sending an instruction set to the microprocessor just once....
8085 SBC EPROM Operation
|complexity-theory|
I didn't read the source you linked, but to prove that $G$ generates **precisely** all well-balanced parentheses you need to show two things: - all words $w$ with well balanced parenthesis are generated by $G$ (this is easy to show by induction), and - all words $w$ generated by $G$ are well-balanced. A gramma...
I didn't read the source you linked, but to prove that $G$ generates **precisely** all well-balanced parentheses you need to show two things: - all words $w$ with well balanced parenthesis are generated by $G$, and - all words $w$ generated by $G$ are well-balanced. A grammar that needs to satisfy the first co...
If you are referring to the binary heap, then you are right that it has something to do with the index. The left child of a node is at index $2*i$ while the right child is $2*(i+1)$, where $i > 0$ is the index of the parent in the array representation of the binary heap. Since a new element is added at the smallest emp...
I am reading Introduction To Theory of Computation by Spiser, 3rd Edition and am confused by his take on the last three cases of proving that "if a language is described by regular expression then it is regular" on Page 67. I **don't understand how this proof guarantees that there will be an NFA for R1 and R2** in ...
Confused by Sipser's proof of equivalence of R and NFAs
|regular-languages|finite-automata|regular-expressions|
We will use the following method to efficiently solve your problem for the case $k = 2$ : We will firstly compute: $$ \begin{array}{rl} S & := A \, \Delta \, B \\ & = (A \setminus B) \cup (B \setminus A) \\ & = (A \cup B) \setminus (A \cap B) \end{array} $$ i.e. the symmetric difference of $A$...
Assume `S` is the start symbol. Assume `1` and `0` are terminal symbols. Assume all other symbols are non-terminal. **Given a set of (non-trivial) grammar rules,** **is it always possible to order them, such that,** **all the symbols on the left:** - **will be contained on the right in a previous rule** - *...
Let's consider $R_1$ only but the idea applies to $R_2$ as well. It should be clear that $R_1$ is a regular expression. Thus, it must be one of the six cases. If it's the first 3, then you are done - construct the NFA for $R_1$ using one of the 3 cases. Otherwise, you can decompose $R_1$ into smaller regular expression...
I am reading Introduction To Theory of Computation by Sipser, 3rd Edition and am confused by his take on the last three cases of proving that "if a language is described by regular expression then it is regular" on Page 67. I **don't understand how this proof guarantees that there will be an NFA for R1 and R2** in ...
This is about unrestricted grammars Assume `S` is the start symbol. Assume `1` and `0` are terminal symbols. Assume all other symbols are non-terminal. **Given a set of (non-trivial) grammar rules,** **is it always possible to order them, such that,** **all the symbols on the left:** - **will be contained...