instruction
stringlengths
0
29.8k
⌀
Knapsack with weight swaps
|dynamic-programming|
(This is mainly about reads, and commercial products not hypothetical machines.) When loading a CPU register with data contained in L2 or L3 of a multi-level cache. Can the data that is in L2 or L3 but not in L1 be read directly, or must the cache line be transferred into L1 before moving to a register? Another way ...
Is loading from L2 or L3 of multi level cache direct or require a transfer to L1
|cpu-cache|
Here's the problem statement (as given on GeeksForGeeks website): Given a sorted dictionary of an alien language having N words and k starting alphabets of standard dictionary, find the order of characters in the alien language. Explanation: We're given a sorted dictionary having N words. Here a dictionary is an...
This answer is a bit more broad. The words safe and safety have in recent decades been mutilated by certain politically oriented parts of English-speaking society, such that their common usage has almost no definition. However, for technical matters I define "safety" and "safe" as a device(physical or procedural) that ...
Safe programming languages (PL) are gaining popularity. What is the **formal definition** of safe PL? For example, C is not safe, but Java is safe. I suspect that the property “safe” should be applied to a PL implementation rather than to the PL itself. If so, how do we define what is a safe PL implementation?
I'm following a book about graphs and they introduce a concept called 'activity network'. In an activity network, each vertex represents an activity in a project (like building a house for example) that needs to be done. An arc between two activities $uv$ means $u$ needs to be done before $v$ and the weight of the arc ...
Algorithm for constructing a numbering reflecting the order of activities
|graphs|weighted-graphs|
I'm following a book about graphs and they introduce a concept called 'activity network'. In an activity network, each vertex represents an activity in a project (like building a house for example) that needs to be done. An arc between two activities $uv$ means $u$ needs to be done before $v$ and the weight of the arc ...
null
This is called [topological sorting](https://en.wikipedia.org/wiki/Topological_sorting). There are many algorithms for topological sorting. The one you list isn't the first I would recommend studying, to learn about this topic. There's no fundamental need for shadow vertices or a bipartite graph. See, e.g., https...
I will only argue about 3), since this is the case you're having troubles with. Consider $\{ 0^i 1^j \mid j \le i \le 2j \}$ for a moment. You can get a CFG for this language by noticing that you can "match" each occurrence of a $1$ to either $1$ or $2$ occurrences of $0$s (in such a way that every occurrence of $0...
Consider $L = \{ a^n b^n a^m \mid m,n\ge 1\}$. In fact you can repeat this to get more equalities $\{ a^n b^n a^m b^m a^k \mid k,m,n\ge 1\}$. Etcetera. Note that we can get really fun things: For $ L = \{ a^n b^{2n} \mid n\ge 1 \}^* \;\cup\; b^+ {\cdot} \{ a^{2n} b^n \mid n\ge 1 \}^* {\cdot} a $ ...
You only need a grammar for i < 2j and i > 2j. Have a symbol X that gets converted to 0, 01, 0X, 0X1 or 0X11, so j < 2i. And a symbol Y that gets converted to 1 or 0Y11Z, with Z converted to eps or Z1, so j > 2i. S -> X | Y X -> 0 | 01 | 0X | 0X1 | 0x11 Y -> 1 | 0Y11Z Z -> eps | Z1
I am currently trying to build a simple computer in Minecraft (8-bit data, 6-bit addresses, no paging or segmentation), with redstone, where I can make run simple programs written similarly to code in the Little Man Computer. However, I have come across the problem that I have no idea which addresses in RAM are free to...
How to find the free memory addresses in RAM?
|memory-management|
Using a 1 way 2 stack, and a 2 way 2 stack PDA, I want to check if the length of a an input string is strictly a perfect square number. How can I do this in both approaches?
1 way 2 stack and 2 way 2 stack Pushdown Accepters that accepts L={a^(n^2)|n≥1}
|automata|finite-automata|pushdown-automata|stacks|
Following bar graph shows maximum percentage cpu utilization of F16sv2 (16vcpu &32GB) azure virtual machine in last 30 days. Only sometimes CPU usage goes more than 60 percentage. 1) How to find the right number of CPU cores for the workload so cpu never goes under utilized? 2) What factors should we consider whil...
How to find optimum number of cpu cores for a workload
|cpu|threads|
Following bar graph shows maximum percentage cpu utilization of F16sv2 (16vcpu &32GB) azure virtual machine in last 30 days. Only sometimes CPU usage goes more than 60 percentage. 1) How to find the right number of CPU cores for the workload so cpu never goes under utilized? 2) What factors should we consider whil...
Following bar graph shows maximum percentage cpu utilization of F16sv2 (16vcpu &32GB) azure virtual machine in last 30 days. Only sometimes CPU usage goes more than 60 percentage. 1) How to find the right number of CPU cores for the workload so cpu never goes under utilized? 2) What factors should we consider whil...
null
Suggestions: "k starting alphabets of standard dictionary" should perhaps be "K letters in the alien alphabet". The "dict = {...}" notation may be misleading. Edit to clarify that this is an ordered list, not a set, by writing $[w_1,w_2,\ldots,w_N]$. Each pair of adjacent words $w_i,w_{i+1}$ in the dictionary list $...
If you have a supervisor that allocates CPUs exclusively to one VM then you should use a different supervisor. You have n real CPUs. The can do n times x amounts of work per second. Whether your VM has 2 CPUs at 100% or 4 CPUs at 50% makes very little difference. Unless you pay per CPU
null
I read the question and answer at https://cs.stackexchange.com/questions/85853/number-of-nodes-of-a-parse-tree-when-the-grammar-is-in-cnf, and I'm curious about a related matter: obviously with a unrestrained LR grammar (as opposed to CNF) the relationship between input length and the number of parse tree nodes depends...
Number of DCFG parse tree nodes with respect to input length
|formal-grammars|parsers|lr-k|
null
null
Having encountered the concept of "pseudopolynomials", my understanding is that we have to be careful when the input to a problem is a number, that the complexity of the solution should be polynomial in the length of its representation and not its value; that is, if we want a solution polynomial in the size of the inpu...
Pseudopolynomials and $NP$ problems like $CLIQUE$
|np|polynomial-time|
null
null
null
null
Let $n$ be a positive integer and $[n] := \{1,2,3,...,n\}$. You are given $k$ non-empty subsets of $[n]$. Decide whether it is possible to: (1) Select exactly one element from each subset; (2) Select some (maybe zero) elements from each subset; such that the elements selected form a permutation of $[n]$. The a...
Choose elements from sets that form a permutation: NP hard?
|polynomial-time-reductions|
Let $n$ be a positive integer and $[n] := \{1,2,3,...,n\}$. You are given $k$ non-empty subsets of $[n]$. Decide whether it is possible to select exactly one element from each subset such that the elements selected form a permutation of $[n]$. I try to reduce the Hamiltonian cycle problem. However, Hamiltonian cycles o...
Is there an algorithm that, given an undirected graph and one independent set **IS1**, finds an other independent set **IS2** by adding and deleting vertices from the first **IS1**?
Independent sets generation in a graph
|algorithms|graphs|independent-sets|
Yes, most algorithms for _enumerating maximal **cliques**_ are based on exactly this principle. Since a clique is just an independent set in the complement, you could simply take $\overline G$ and enumerate cliques. Of course, if your graph is very sparse, this might in practice not be a good idea. The trivial bra...
It is currently unknown whether your problem is NP-Hard. However, if it were, then it would be the case that P=NP. To solve the problem in polynomial-time you can check whether a maximum matching in the following bipartite graph $G=(U \cup V, E)$ has size $n$: - The set $U$ is $u_1, \dots, u_n$. - The set $V$ is $...
The number $K$ of iterations of the loop is exponential in the size of the representation of $K$ (which is $\log K$) but it is polynomial in the size of the *input* of the problem. The input of the problem is not just the integer $K$ but both the graph $G$ and $K$. The size of the representation of $G$ is $\Omega(|V|...
null
null
Specifically, properties that identify preconditions over which a function can be used without resulting in undefined behavior or data races. For example, I am familiar with 3 important properties: * [pure](https://en.wikipedia.org/wiki/Pure_function) * [idempotent](https://en.wikipedia.org/wiki/Idempotence) * ...
What are the non-overlapping properties of a function?
|functional-programming|
null
null
Each pair of adjacent words $w_i,w_{i+1}$ in the dictionary list $[w_1,\ldots,w_N]$ generates at most one edge in the DAG. Why "at most"? (a) because that edge may be present already and (b) because $w_i$ could be a prefix of $w_{i+1}$. The suggested $N-1$ comparisons suffice because nothing new can be learned from stu...
In Arora-Barak, the authors mention a way how TMs can compute everything that can be computed by computers. The idea is that every high-level language program has an equivalent machine language program which is basically a sequence of instructions. These instructions are easy enough to be implemented in TMs. I am attac...
In the simulation of a C-program by a Turing machine, how does a TM determine which instruction to execute?
|turing-machines|programming-languages|
null
null
Consider we use a RAM model with word length w (or if you really want to, Knuth's MMIX). Given a number n, we want to compute the most significant digit. For least significant digit, this is pretty easy: $n - 10 \lfloor {n\over{10}} \rfloor$ which is O(1). Is there a similar O(1) algorithm for computing t...
Can we compute most significant digit of a binary number in O(1) on RAM model?
|algorithms|
null
The tape of the TM stores the code of the program (the sequence of machine instructions), followed by the memory of the program. You design a TM that traverses back and forth between the code section (to find the next instruction to execute) and the memory section (to execute that one instruction and update memory app...
The memory allocator is typically responsible for keeping track of which areas in memory are free. For instance, the memory allocator might keep a list of which regions of memory are free and available for allocation. This is called, appropriately, the "free list". See https://en.wikipedia.org/wiki/Free_list and htt...
They aren't trying to show that there is a single Turing machine that can run every C program (although that's also true). They're trying to show that for every C program, there is some Turing machine equivalent to it. Every C program compiles to a fixed finite number of machine instructions, so you can encode them as ...
I am looking for algorithms (or at least something similar to the problem definition): Given a fully-connected graph G of N nodes, find a square lattice graph (where each node, except for the ones at the edges, is connected to 4 other nodes) such that the sum of edges in the lattice is minimal? I haven't been abl...
Fully Connected Graph to Lattice
|graphs|lattices|
null
null
I am pretty new to ATP, but I'm really enjoying playing around with prover9. I have found a nice set of axioms for basic information-theoretic proofs [here][1], I was wondering if there are some collections of axioms for other purposes too, e.g. probability theory. I found a gigantic set of axioms for TPTP programs ...
null
Specifically, properties that identify preconditions over which a function can be used without resulting in undefined behavior or data races. For example, I am familiar with 3 important properties: * [pure](https://en.wikipedia.org/wiki/Pure_function) * [idempotent](https://en.wikipedia.org/wiki/Idempotence) * ...
There is no complete properties. You can always find one more. In particular, a property is just a subset of functions, and there are infinitely many functions, so there are infinitely many properties. Assuming I have understood your definition of non-overlapping correctly, these three are non-overlapping. An ide...
Take this C code: int* p; *p = 1; C is a very unsafe language. p is uninitialised, so it could point anywhere. Likely effects are an immediate crash, overwriting memory somewhere with no bad side effect, or overwriting something important, and then Things Go Wrong. Now we change it to int* p = NUL...
Interaction nets are a form of graph rewriting. Nets are graphs made up of some finite number of labelled nodes with connections between them. If two nodes have the same label then they have the same number of ports, that is places where they can connect to other nodes. Exactly one of these ports is noted as a "prin...
I am having trouble with the statement that $DSPACE(\log^2n)\subseteq DTIME(n^{\log n})$ holds which is given without argument in the paper [The structure and complexity of minimal NFA's over a unary alphabet][1] in the proof of Theorem 3.2. I only get to something like $DSPACE(\log^2n)\subseteq DTIME(\log n)$. (Usi...
Why is $DSPACE(\log^2n)\subseteq DTIME(n^{\log n})$?
|time-complexity|turing-machines|space-complexity|transducers|
[this][1] recently published paper (open access) claims to have resolved the question of uniqueness. [1]: https://www.sciencedirect.com/science/article/pii/S0899825623001033
I am having trouble with the statement that $DSPACE(\log^2n)\subseteq DTIME(n^{\log n})$ holds which is given without argument in the paper [The structure and complexity of minimal NFA's over a unary alphabet][1] in the proof of Theorem 3.2. I only get to something like $DSPACE(\log^2n)\subseteq DTIME(\log n)$. (Usi...
Your processor may use read/write instructions to access hardware, in that case some pages will be marked as uncached, so a read of 4 bytes will directly read from an address that is most likely not connected to RAM. Otherwise: I have never seen instructions that let you control this, the default is obviously going...
I am attempting to draw the DFA of this problem but I'm kind of stuck. In another post I saw that the DFA should have 10 states. I'm finding it hard to even understand the question, is the input to the DFA the full string so for example 1001 or is it multiple inputs of length 3 in this example 100 and then 001. I've ma...
Create DFA such that every substring of w of length 3 contains two or three 0's with w={0,1}
|finite-automata|
null
In role playing games, switching equipment for better is a common procedure. My question is to find an algorithm that can optimize linear combination of stats the equipped gear gives - this is exactly how it works on The-West.net: - Each piece of equipment can be equipped in only one slot (there is approximately 5-1...
Optimize clothing in RPG considering set bonuses
|dynamic-programming|constraint-programming|
I am attempting to draw the DFA of this problem but I'm kind of stuck. In another post I saw that the DFA should have 10 states. I'm finding it hard to even understand the question, is the input to the DFA the full string so for example 1001 or is it multiple inputs of length 3 in this example 100 and then 001. I've ma...
I am attempting to draw the DFA of this problem but I'm kind of stuck. In another post I saw that the DFA should have 10 states. I'm finding it hard to even understand the question, is the input to the DFA the full string so for example 1001 or is it multiple inputs of length 3 in this example 100 and then 001. I've ma...