instruction
stringlengths
0
29.8k
⌀
I'm learning about the (min-mean) cycle-cancelling alg for min-cost flow in Ahuja, Magnanti, and Orlan's Network Flows book (Chapters 9 and 10). When talking about the alg, they prove this fact related to the $\epsilon$-optimality of a flow: > **Lemma 10.14**: For a nonoptimal flow $x$, if we cancel a minimum mean ...
epsilon-optimality in cycle-cancelling for min cost flow
|algorithms|graphs|network-flow|
I am trying to understand the personalised page rank algorithm. I have a graph with multiple types of nodes and I want to calculate how important other nodes are w.r.t these nodes. I am using personalised page rank algorithm for the same. I followed the notes from this blog https://medium.com/polo-club-of-data-sc...
According to the book " Operating Systems Concepts ", ninth edition , page 210, we have the following statement : > Many modern computer systems therefore provide special hardware > instructions that allow us either to test and modify the content of a > word or to swap the contents of two words atomically—that is...
Process Synchronization and Atomic Instructions
|operating-systems|synchronization|
null
null
Given the grammar with productions: \begin{align} S \rightarrow aSb \mid SS \mid \lambda\\ \end{align} I would like to show that it is ambiguous. As I understand it, if you can show that some string can be produced with these rules through more than one leftmost or rightmost derivation, then the grammar is ambiguou...
Derivation trees to show a given grammar is ambiguous
|context-free|formal-grammars|ambiguity|
This is just a matter of wording. “Uninterruptible” implies that the instruction cannot execute in parallel with an identical instruction - that would be the ultimate interruption. But that’s implementation details. The important thing is that these operations are _atomic_. That is _indivisible_. If the description...
null
I believe your professor is wrong. You exhibited two leftmost derivations, which is all that is required to show a grammar is ambiguous. Although, one small thing: $S \Rightarrow SS \Rightarrow aSbS \Rightarrow a\lambda b\lambda \Rightarrow ab$ should have another rule as you have followed two rules at once, $S \Righta...
Let us say that I wanted to solve a Hamiltonian path problem by treating it as a Hamiltonian cycle(on a weighted graph). I use a TSP solver, and implement a dummy node of edge weight zero, whose distance to every other node on the graph is equal to zero. Can I run Dijkstra's algorithm (either alone, or with other DP fu...
Can Dijkstra's algorithm be used this way?
|algorithms|graphs|graph-traversal|weighted-graphs|
I could be misunderstanding you, but the answer is no. Dijkstra's requires you to specify the start node and the end node, and returns the shortest path between them.(It can actually tell you the shortest path from the start node to every other node, but that isn't crucial here.) There is no reason that this path would...
null
null
null
null
null
null
null
null
null
null
null
This is for the leetcode problem 169. Majority Element. Given an array of numbers, where there is a guarantee that there is a number that exists in the array greater than floor(n/2), one can find such a number by selecting a random index and checking if it's value is the majority element or not, and repeat until it's f...
Runtime of randomization algorithm to find majority element in an array?
|algorithms|time-complexity|algorithm-analysis|runtime-analysis|randomized-algorithms|
null
null
null
You say you're seeking solid foundation in Computer science and Electrical Engineering. There is not a school in this world that teaches these subjects without teaching not only theory of computation, but also linear algebra, analysis, logic, and discrete mathematics. These *are* the foundations, and are unavoidable. ...
For an n-bit by n-bit multiplier you use $n^2$ ANDs which each give a single bit in some bit position. For example in a 64 bit multiplier $x_{52} and $y_{22} would be a bit in position 74. You arrange this in columns for each bit position, then any three bits in the same position are added with a full adder, giving...
null
The typical definition of an RMW instruction with e.g. sequential consistency is an instruction where no memory operation can happen between the load and the store in the global memory order. Is there a reason to use this definition? Why is it not sufficient to just require that no operation to the same memory addre...
Memory ordering and RMW instruction definitions
|consistency-model|
Let’s say somewhere in your circuit there is a logical AND calculating a AND b. Now as you change the inputs that change will move through your circuit and change things. a and b start with a certain state. The inputs can affect them in faster and slower ways, until eventually the outputs are stable. Now it is poss...
A "half adder" only does half the job: It adds two inputs x and y. A "full adder" does the full job: Most of the time, you need to process two inputs, plus a carry from another (half or full adder). A "full adder" adds three inputs x, y and z. You will also find the terms 2-2 or 3-2 adders: A 3-2 adder adds 3 in...
I am trying to wrap my head around the following proof - Choose some language *A* $\in$ $TIME(n^3)$ \ $TIME(n)$ (the existence of such a language is guaranteer by the hierarchy theorem) - Let *B* = {1} - Note that $A \leqslant_{p} B, B \in TIME(n)$ but $A \not\in TIME(n^{3})$ The way I understand is that *...
Showing TIME(n) is not closed under poly-time reduction
|complexity-theory|
null
null
My apologies if the title is confusing. First I begin with the statement that may be wrong but what I always thought what happened. "Dennis Ritchie created C compiler which was used to create other Unix or Linux compilers, which helped us create current Linux eco system." The idea behind this was that if you take...
What is the earliest compiler in chain that was used to create what we nowadays have as a modern C compiler?
|programming-languages|compilers|history|
I have 'solved' this, but I could use some help figuring out how to apply it correctly as a pattern to grayscale images at different angles. The solution uses rectangles whose corner radius changes. When the corner radius is half the length of the sides of the rectangles, it will appear to be a circle. My solutio...
I have 'solved' this, but I could use some help figuring out how to apply it correctly as a pattern to grayscale images at different angles. The solution uses rectangles whose corner radius changes. When the corner radius is half the length of the sides of the rectangles, they will appear to be circles. My soluti...
I have 'solved' this, but I could use some help figuring out how to apply it correctly as a pattern to grayscale images at different angles. The solution uses rectangles whose corner radius changes. When the corner radius is half the length of the sides of the rectangles, they will appear to be circles. My soluti...
I have 'solved' this, but I could use some help figuring out how to apply it correctly as a pattern to grayscale images at different angles. The solution uses rectangles whose corner radius changes. When the corner radius is half the length of the sides of the rectangles, they will appear to be circles. My soluti...
if the ambiguity was the problem, then your solution is completely correct, showing 1 example, where derivation isn't unique is enough to prove that grammar is ambiguous in this case.
by the closure property of context-free languages, if L is context-free, then L^R (reverse of L) is also context-free, but L∩L^R might be non-context-free. I tried to come up with an example of L, but seems the set of L∩L^R could only have palindromes (including languages like aaa...) and empty strings. However, palind...
Does there exist an context free language L such that L∩L^R is not context free?
|context-free|closure-properties|computational-linguistics|
Consider $\{ 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.
By the closure property of context-free languages, if $L$ is context-free, then $L^R$ (the reverse of $L$) is also context-free, but $L\cap L^R$ might be non-context-free. I tried to come up with an example of $L$, but it seems the set of $L \cap L^R$ could only have palindromes (including languages like $aaa \ldots$) ...
null
null
I am currently facing a question "Can a graph with a unique MST product a different spanning graph using Dijkstra vs using Prim's algorithm?" The answer is false and I am struggling to understand why (and also to come up with a counter example)...
Graph Algorithms (SSSP vs MST)
|graphs|weighted-graphs|
null
A graph with a unique MST $T$ can definitely have a SPT that differs from $T$. In fact, there are graphs where both the MST and the SPT (from a given source) are unique (so it doesn't matter which algorithms you use to compute them) and these two trees differ. Consider for example a triangle graph with vertices $...
Suppose the following fill-in-the-blanks exercise: ___ ___ and ___ ___ went to the ___. Suppose the correct solution here is "John Smith and Mike Jones went to the pub". In other words: `[John, Smith, Mike, Jones, pub]`. But the following alternate solution should count as well - the persons are swapped but th...
How to check for correct order in a fill-in-the-blanks exercise
|algorithms|
null
My apologies if the title is confusing. First I begin with the statement that may be wrong but what I always thought what happened. "Dennis Ritchie created C compiler which was used to create other Unix or Linux compilers, which helped us create current Linux eco system." The idea behind this was that if you take...
According to me if no. of a's is greater than no. Of b's and once the pushing of string a is completed then we start popping out every a for every b,then at last more than 1 a will be left in the stack .Hence keeping this concept in mind you can draw the transition diagram and table as well.
According to me if no. of a's is greater than no. Of b's and once the pushing of string a is completed in the stack then we start popping out every a for every b we get,then at last more than 1 no. Of a will be left in the stack as no. Of a's is greater in no..Hence keeping this concept in mind you can draw the transi...
null
Consider $\{ 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 $ $L\...
I know that Dijkstra's algorithm is used to find the shortest path between nodes in a weighted graph. And I know that this can be used to model road networks. Somebody online asked (but nobody answered) how one would go about modifying Dijkstra's algorithm to determine if an electric car can travel to every town in ...
How to modify Dijkstra's algorithm to model the path of an electric car?
I'm a mathematics undergraduate interested in theoretical computer science, machine learning, and neuroscience. I wish to pursue graduate studies in computer science but I fear I might not be able to since I haven't and won't be allowed to take any computer science courses for the rest of my undergraduate years. My cu...
Transitioning from mathematics to computer science
|career|
I'm a mathematics undergraduate interested in theoretical computer science, machine learning, and neuroscience. I wish to pursue graduate studies in computer science but I fear I might not be able to since I haven't and won't be allowed to take any computer science courses for the rest of my undergraduate years. My cu...
null
null
I am trying to understand the personalised page rank algorithm. I have a graph with multiple types of nodes and I want to calculate how important other nodes are w.r.t these nodes. I am using personalised page rank algorithm for the same. I followed the notes from this blog https://medium.com/polo-club-of-data-sc...
null
null
null
null
I have 'solved' this, but I could use some help figuring out how to apply it correctly as a pattern to grayscale images at different angles. The solution uses rectangles whose corner radius changes. When the corner radius is half the length of the sides of the rectangles, they will appear to be circles. My soluti...
null
I am having trouble with a problem where I am given an adjacency list and a list of the nodes that must be visited exactly once to connect two nodes. What is the most efficient way of doing this? This problem is the [Hamiltonian Path][1] problem except it is only certain nodes that have to obey this principle. Let me k...
Algorithm question - check if there exists a path that touches A nodes exactly once and can revisit all other nodes
|algorithms|complexity-theory|graphs|hamiltonian-path|
You can't do it in polynomial time (unless P = NP), since it is as hard as the Hamiltonian path problem (consider the special case where you must visit all nodes). One standard approach if you have to solve it in problem and the graph is small enough is to use a SAT solver.
One of the conventional examples of languages that are not context-free is $X = \{ a^n b^n a^n | n \geq 0 \}$. You can use that to construct an example of what you are looking for by setting $L = \{ a^n b^n a^m | n,m \geq 0 \}$. $L$ is clearly context-free but $L \cap L^R = M$. You can use similar tricks to construc...
null
I have a problem that is 0/1 knapsack, but you are also able to swap the weight of 2 items up to k times. I came up with a O(n*k*c) solution, but I am looking for a faster o(n*c) solution. I think the intuition is we should use all k swaps unless we can use less than k swaps and use all of the max values with the minim...