instruction
stringlengths
0
29.8k
⌀
Stack Program Counter
|stacks|assembly|
null
I was just wondering if there exists problems that are solvable in polynomial time (a correct solution can be found in polynomial time) but not verifiable in polynomial time. My professor says no, but doesn't rlly give a clear explanation besides saying you can just use the solution to verify, but I fail to see how thi...
Problems in P but not Verifiable in NP
|algorithms|np|p-vs-np|
When you perform a `call`, you jump into a proceduce that can `ret`, effectively doing similar work to how a usual function call works. You run a function, and after it completes - you continue in the line after the call. In contrast, `jmp` should not be called into procedures that use `ret`, which means that it will ...
**Problem**: find all anagrams in a string such that one substring can be formed from another substring by rearranging its letters. Given a string $s$, find the number of pairs of substrings of the string that are anagrams of each other. Below is the traditional solution to this problem that uses $O(n^2\times n\lo...
{"Voters":[{"Id":155618,"DisplayName":"kim120"}]}
No, the verification algorithm will just use the solving algorithm and will ignore the verification "proof" it gets. I.e, a verifier is a TM $V(x,w)$, such that $x\in L\iff \exists w, |w|\text{ is polynomial and } V(x,w)=true$. Therefore, if $V$ completely ignores $w$ and uses the solving procedure to check if $x\in ...
Global variables exist as unique instances, which are known at program compilation and can be preallocated some space. Local variables are only needed if the functions are called. So - they are not allocated in advance, - if there are recursive calls or mutually recursive calls (A calls B and B calls A), there...
When you perform a `call`, you jump into a proceduce that can `ret`, effectively doing similar work to how a usual function call works. You run a function, and after it completes - you continue in the line after the `call`. In contrast, `jmp` should not be called into procedures that use `ret`, which means that it wil...
{"Voters":[{"Id":155618,"DisplayName":"kim120"}]}
The verification algorithm will just use the solving algorithm and will ignore the verification "proof" it gets. I.e, a verifier is a TM $V(x,w)$, such that $x\in L\iff \exists w, |w|\text{ is polynomial and } V(x,w)=true$. Therefore, if $V$ completely ignores $w$ and uses the solving procedure to check if $x\in L$, ...
You are on the right track. A bit more work is needed. ------ Suppose we have developed a comparison-based MST algorithm $\mathcal A$ for graphs of distinct edge-weights. (You will probably not see an MST algorithm that is not comparison-based.) Let $G=(E,V,w)$ be a weighted graph where edge-weights might have...
Under normal circumstances, the program counter is just incremented i.e. the next instruction is executed. When you call a function, instead of the next instruction, some other instruction needs to be executed, and after completing the function you need to go back and execute the next instruction after the function cal...
{"Voters":[{"Id":155618,"DisplayName":"kim120"}]}
null
My lecture notes for minimum spanning trees say that: > A graph can have several minimum spanning trees but if the edge weights are distinct then the minimum spanning tree is unique. Without loss of generality, we can assume that the edge weights are distinct I'm trying to convince myself that the distinct edge ...
The verification algorithm will just use the solving algorithm and will ignore the verification "proof" it gets. I.e, a verifier is a TM $V(x,w)$, such that $x\in L\iff \exists w, |w|\text{ is polynomial and } V(x,w)=true$. Therefore, if $V$ completely ignores $w$ and uses the solving procedure to check if $x\in ...
null
null
There are three types of memory in C: static (global variables), automatic (stack) and dynamic (heap). All three are needed to express programs conveniently and efficiently. ### Why static memory is necessary Why you can't have just automatic and dynamic memory: It's mostly possible — after all, a local variable ...
|memory-management|c|language-design|
null
{"Voters":[{"Id":155618,"DisplayName":"kim120"}]}
You have a problem in P. This means you have an algorithm X that will tell you whether the answer for an instance is yes or no, in polynomial time. Now I create a verifier. A verifier takes an instance and some information that is supposed to help it, and will return in polynomial time an answer “yes” if the correc...
Ignoring the question title, it appears you are asking about problems for which there may be more than one correct answer for a given input. In that case, there may exist a polynomial-time algorithm that finds a solution, but no algorithm that can verify arbitrary solutions. For example, given any string, it's easy ...
null
null
Let $\Delta_n :=${$x\in \mathbb{R}^n\colon \sum_{i=1}^n x_i = 1$} denote the probability simplex in $\mathbb{R}^n$ and $A^{n \times n}$ be diagonalizable matrix. I would like to know what is the fastest way (computationally-speaking) of solving the problem $\text{argmin}_{x\in \Delta_n} ||A x -y||^2$. When $A=I$...
Finding $\text{argmin}_{x\in \Delta_n} ||A x -y||^2$
|optimization|quadratic-programming|
I'm not sure how to show that the language L = {M | M is a TM and {b}* ∩ L(M) ≠ ∅ } is recursively enumerable. I understand that if there is a DTM that accepts every word of the given alphabet, it is recursively enumerable. But I dont know how to properly show this, can anyone help?
Show that Language L = { <M> | M is a TM and {b}* ∩ L(M) ≠ ∅ } is recursively enumerable?
|formal-languages|turing-machines|proof-techniques|recursively-enumerable|
Let $\Delta_n :=${$x\in \mathbb{R}^n\colon \sum_{i=1}^n x_i = 1$} denote the probability simplex in $\mathbb{R}^n$ and $A^{n \times n}$ be diagonalizable matrix. I would like to know what is the fastest way (computationally-speaking) of solving the problem $\text{argmin}_{x\in \Delta_n} ||A x -y||^2$. When $A=I$...
null
null
null
null
null
I am struggling with this question as I am not sure whether the answer that has been provided is correct or not. The image should be sufficient to tell the question. <br>The attached image is of the answer. For the question, imagine all but the first two columns are empty.[![enter image description here][1]][1] <br>...
Help with a question on write-through and no-write allocate in caches
|computer-architecture|cpu-cache|
I'm taking a course about the formality of programming languages and while reading Semantics with Applications: An Appetizer by H.R Nielson and F. Nielson I came across the following exercise: [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/RbYG6.png I'm referring to the last statemen...
Semantics Equivalence of Structural Semantics of While Programming Language
|programming-languages|types-and-programming-languages|operational-semantics|
null
null
Because **functions can be recursive**. Since a function may call itself (in)directly, the compiler needs to ensure that the nested invocation gets its own variables. And the stack is the most simple solution for that. As a matter of fact, early FORTRAN did not allow for recursive functions. And guess what, that ...
I was just wondering if there exists problems that are solvable in polynomial time (a correct solution can be found in polynomial time) but not verifiable in polynomial time. My professor says no, but doesn't rlly give a clear explanation besides saying you can just use the solution to verify, but I fail to see how thi...
Problems Solvable in Poly time but not verifiable in Poly time
Prove/disprove: if $L\in coRE~then~L\leq _m PAL_{TM}$ $PAL_{TM} = ${$<M,w>| M~is~a~TM~and~w~is~a~palindrome$} It feels like there's not necessarily a mapping reduction from every language to a harder language, but I couldn't find a counter example or disprove the claim (How do I prove that a mapping doesn't exist...
Prove that if a language is in co-RE it doesn't mean that it's mapping reducible to another language
|complexity-theory|turing-machines|computability|
One way to prove that a reduction doesn't exist is to prove that if a reduction *did* exist, it would lead to some result that is incompatible with the premise. So, suppose such a reduction did exist. What could you say about the complexity class of $L$, using that reduction?
Prove/disprove: if $L\in \text{coRE}$ then $L$ is mapping-reducible to $\text{PAL}_{\text{TM}}$, where $\text{PAL}_{\text{TM}} = \{~\langle M,w\rangle ~|~ M ~\text{is a TM and}~w~\text{is a palindrome}~\}$ It feels like there's not necessarily a mapping reduction from every language to a harder language, but I co...
null
I'm taking a course about the formality of programming languages and while reading Semantics with Applications: An Appetizer by H.R Nielson and F. Nielson I came across the following exercise: [![enter image description here][1]][1] I'm referring to the last statement - I managed to proof that the statement is s...
It is very easy to disprove the claim that if L is in co-RE, then L must be mapping reducible to $PAL_{TM}$. Consider a simple language such as the empty language, denoted as $∅$. This language contains no strings, so it is not a palindrome language, and therefore cannot be mapped reducible to $PAL_{TM}$. Howe...
Prove/disprove: if $L\in \text{coRE}$ then $L$ is mapping-reducible to $\text{PAL}_{\text{TM}}$, where $\text{PAL}_{\text{TM}} = \{~\langle M,w\rangle ~|~ M ~\text{is a TM and}~w~\text{is a palindrome}~\}$ It feels like there's not necessarily a mapping reduction from every language to a harder language, but I co...
I'm given a description of a regular language $L$, and I have a candidate regular expression. Is there a systematic, step-by-step way to test whether the candidate regular expression is correct? I know that there can be multiple regular expressions that are correct. <sup>This is intended as a reference we can po...
Check whether a regular expression is correct
|regular-languages|finite-automata|regular-expressions|
I'm given a description of a regular language $L$, and I have a candidate regular expression $R$. Is there a systematic, step-by-step way to test whether the candidate regular expression is correct? I know that there can be multiple regular expressions that are correct. <sup>This is intended as a reference we ca...
I'm new to optimization and I have a little problem that I want to resolve with my job. Here we go! I need a certain number of drivers per day and each driver has 2 consecutive days off during the week. My optimization problem is that I want to have as few employees as possible with the number of driver per week. I ...
Java optimization and minimization
|optimization|java|
Let $\Sigma$ be an alphabet, and denote by $\mathrm{ind}(\varphi_M^{(k)})$ the index set (w.r.t some numbering) of the $k$-ary partial computable function $\varphi_M^{(k)} : (\Sigma^*)^k \rightarrow \Sigma^*$, which is also the $k$-ary proper function of the Turing machine $M$. Is it the case that $\mathrm{ind}(\varphi...
Indices of Turing machine on different arity inputs
|turing-machines|computability|
Let $\Sigma$ be an alphabet, and denote by $\mathrm{ind}(\varphi_M^{(k)})$ the index set (w.r.t some numbering) of the $k$-ary partial computable function $\varphi_M^{(k)} : (\Sigma^*)^k \rightarrow \Sigma^*$, which is also the $k$-ary proper function of the Turing machine $M$. Is it the case that $\mathrm{ind}(\varphi...
Let $\Sigma$ be an alphabet, and denote by $\mathrm{ind}(\varphi_M^{(k)})$ the index set (w.r.t some numbering) of the $k$-ary partial computable function $\varphi_M^{(k)} : (\Sigma^*)^k \rightarrow \Sigma^*$, which is also the $k$-ary proper function of the Turing machine $M$. Is it the case that $\mathrm{ind}(\varphi...
"The grammar is ambiguous. But the language is regular. So if you figure out what the language is, you can easily write an unambiguous grammar", says rici. Denote the language generated by the given grammar by $L$. Let us see what is $L$ in plain English. Or how we can describe the strings in $L$. Or how we can gene...
|formal-grammars|compilers|ambiguity|
Yes. It depends how the regular language $L$ is specified. I describe below an algorithm for this problem, i.e., a systematic procedure that you can follow to check correctness. You can simulate running such an algorithm by hand, with pencil-and-paper, if necessary: it might be tedious, but it works. Even better ye...
Yes. It depends how the regular language $L$ is specified. I describe below an algorithm for this problem, i.e., a systematic procedure that you can follow to check correctness. You can simulate running such an algorithm by hand, with pencil-and-paper, if necessary: it might be tedious, but it works. Even better ye...
Yes. It depends how the regular language $L$ is specified. I describe below an algorithm for this problem, i.e., a systematic procedure that you can follow to check correctness. You can simulate running such an algorithm by hand, with pencil-and-paper, if necessary: it might be tedious, but it works. Even better ye...
{"OriginalQuestionIds":[156003],"Voters":[{"Id":755,"DisplayName":"D.W."}]}
{"OriginalQuestionIds":[45570],"Voters":[{"Id":755,"DisplayName":"D.W."}]}
{"OriginalQuestionIds":[45570],"Voters":[{"Id":755,"DisplayName":"D.W."}]}
{"OriginalQuestionIds":[71221],"Voters":[{"Id":755,"DisplayName":"D.W."}]}
{"OriginalQuestionIds":[156003],"Voters":[{"Id":755,"DisplayName":"D.W."}]}
{"OriginalQuestionIds":[148817],"Voters":[{"Id":755,"DisplayName":"D.W."}]}
{"OriginalQuestionIds":[2016],"Voters":[{"Id":755,"DisplayName":"D.W."}]}
"The grammar is ambiguous. But the language is regular. So if you figure out what the language is, you can easily write an unambiguous grammar", says rici. Denote the language generated by the given grammar by $L$. Let us see what is $L$ in plain English. Or how we can describe the strings in $L$. Or how we can gene...
You can solve this with linear programming. Let's start with the variables. Let $x_d$ denote the number of drivers whose work week starts on day $d$, e.g., $x_\text{Monday}$ denotes the number of drivers who work Monday, Tuesday, Wednesday, Thursday, Friday, and have Saturday and Sunday off. Next the inequalitie...
$\textit{2OrMoreSAT} = \{\langle \phi \rangle \mid \phi \text{ is a boolean formula in CNF, which has two or more true literals per clause} \}$ The literals must be different. I want to solve this by reducing 3SAT to 2OrMoreSAT. My first thought was to duplicate all of the literals in a clause, which would ensure 2 ...
How to reduce 3SAT to TwoOrMoreSAT is NP-Complete?
|complexity-theory|np-complete|satisfiability|3-sat|
How to reduce 3SAT to TwoOrMoreSAT?
I want to prove, that 2OrMoreSAT is NP-complete. It's defined as follows: $\textit{2OrMoreSAT} = \{\langle \phi \rangle \mid \phi \text{ is a boolean formula in CNF, which has two or more true literals per clause} \}$ The literals must be different. I want to solve this by reducing 3SAT to 2OrMoreSAT. My first th...
I want to prove, that 2OrMoreSAT is NP-complete. It's defined as follows: $\textit{2OrMoreSAT} = \{\langle \phi' \rangle \mid \phi' \text{ is a boolean formula in CNF, which has two or more true literals per clause} \}$ The literals must be different. I want to solve this by reducing 3SAT to 2OrMoreSAT. My first ...
You can solve this with linear programming. Let's start with the variables. Let $x_d$ denote the number of drivers whose work week starts on day $d$, e.g., $x_\text{Monday}$ denotes the number of drivers who work Monday, Tuesday, Wednesday, Thursday, Friday, and have Saturday and Sunday off. Next the inequalitie...
I've read characteristics of the following: linearity, homogenous, static/dynamic. Often used to describe concrete data type or the abstract data type. Often these are built by users using non-primitive data types like combinations of object and methods. But when viewing the primitive data types from a low level la...
In data structures, there are many identifiable characteristics, but what are the characteristics are of primitive-data types?
|data-structures|language-design|
I want to prove, that 2OrMoreSAT is NP-complete. It's defined as follows: A formula is considered strongly satisfiable if there exists a model such that two or more literals evaluate to true. $\textit{2OrMoreSAT} = \{\langle \phi' \rangle \mid \phi' \text{ is a boolean formula in CNF which is strongly satisfiable...
I want to prove, that 2OrMoreSAT is NP-complete. It's defined as follows: A formula is considered strongly satisfiable if there exists a model such that two or more literals different literals in every clause evaluate to true. $\textit{2OrMoreSAT} = \{\langle \phi' \rangle \mid \phi' \text{ is a boolean formula i...