instruction stringlengths 0 29.8k ⌀ |
|---|
Why doesn't the Floyd-Warshall algorithm work if I put k in the innermost loop |
null |
Take $i - 1$ and $j = 2$. The algorithm is trying to find the shortest path between $1$ and $2$, by considering intermediate vertices. But at this point, most of the array dist is infinity, so we don't even find that $2$ is reachable from $1$ unless the distance is $1$ or $2$. |
Studying Quick-Find and Quick-Union heuristic I've found clear that:
- with quick find trees and a union based on the size of the trees we can make a union in $T_{am}(n)=O(\log(n))$
- with quick find trees and a union based on the height of the trees we can make a find in $T(n)=O(\log(n))$
But I read that usin... |
I often read that deciding whether or not a number $r$ is a quadratic residue modulo $n$ is an interesting (and hard) problem from number theory (especially if $n$ is not prime).
I am looking at the following special case of this problem: Let $p$ and $q$ be two different prime numbers and $n:=pq$. Given $r$ between... |
Quadratic residue and integer factoring |
|cryptography|number-theory| |
To union-by-size two trees, you have to find their roots first. Since union-by-size takes logarithmic time (your first bullet), then first must take logarithmic time as well.
Here is a more formal argument. Say you want to union-by-size two trees $T_1$ and $T_2$. Assume that their heights are logarithmic in their si... |
We want to tile $m\times m$-square using two types of tiles: $1 \times 1$-square tile and $2 \times 2$-square tile such that every underlying square is covered without overlapping. Let us define a function $f(n)$ that gives the size of largest uniquely tillable square using $n$ $1\times 1$-squares and any number of $2 ... |
We want to tile $m\times m$-square using two types of tiles: $1 \times 1$-square tile and $2 \times 2$-square tile such that every underlying square is covered without overlapping. Let us define a function $f(n)$ that gives the size of largest uniquely tillable square using $n$ $1\times 1$-squares and any number of $2 ... |
We want to tile $m\times m$-square using two types of tiles: $1 \times 1$-square tile and $2 \times 2$-square tile such that every underlying square is covered without overlapping. Let us define a function $f(n)$ that gives the size of largest uniquely tillable square using $n$ $1\times 1$-squares and any number of $2 ... |
null |
Finding all solutions to subset sum for integers with bounded weights |
The approach of the algorithm is dynamic programming. This means that during computation only partial solutions are determined. Here $k$ is an important parameter in the algorithm. When dealing with $k$, shortest paths are computed that are only allowed to pass vertices $1$ upto $k$, the other vertices can only be init... |
As far as a I understand it, a regular language is a set of words that can be run in a DFA.
L1 = { x#y | x,y ∈ {0,1}* and |x| = |y| }
L2 = { xy | x,y ∈ {0,1}* and |x| = |y| }
L1 is not regular but L2 is, why is that?
Is it possible to create a DFA that accepts L2 (it needs to remember the length of x) if so,... |
Regular languages - models of computation |
|regular-expressions| |
There is a paper that did a good experiment over these string matching algorithms for different patterns:
"[Comparison of string matching algorithms: an aid to information content security][1]"
Also there is a study of these string matching algorithms for Japanese language:
[Comparison and Improvement of String Ma... |
As far as a I understand, a regular language is a set of words that can be run in a DFA.
$L_1 = \{ x\#y \mid x,y \in \{0,1\}^* \ \text{and} \ |x| = |y| \}$
$L_2 = \{ xy \mid x,y \in \{0,1\}^* \ \text{and} \ |x| = |y| \}$
$L_1$ is not regular but $L_2$ is, why is that?
Is it possible to create a DFA that acce... |
Does $\mathsf{NSPACE}( f (n)) = \mathsf{coNSPACE}( f (n))$ hold for $ f(n) \geq \log (n) $? |
Why would a company like Twitter be interest in algebraic concepts like groups, monoids and rings. https://github.com/twitter/algebird
All I could find is:
> Implementations of Monoids for interesting approximation algorithms,
> such as [Bloom filter][1], [HyperLogLog][2] and [CountMinSketch][3]. These allow you... |
What use are groups, monoids, and rings in computation? |
|discrete-mathematics|database-theory|computer-algebra|group-theory| |
null |
Here is an "explicit" construction of uncountably many non-computable Boolean functions. Let $K$ be some fixed non-computable Boolean function, say the characteristic function of the halting problem. Consider the set of functions
$$ F = \{ f \colon \mathbb{N} \to \{0,1\} : \forall x \in \mathbb{N}, f(2x) = K(x) \}. $$... |
I haven't read this anywhere, but this is how I believe $Y$ could have been derived:
Let's have a recursive function $f$, perhaps a factorial or anything else like that. Informally, we define $f$ as pseudo-lambda term where $f$ occurs in its own definition:
$$f = \ldots f \ldots f \ldots $$
First, we realize t... |
I haven't read this anywhere, but this is how I believe $Y$ could have been derived:
Let's have a recursive function $f$, perhaps a factorial or anything else like that. Informally, we define $f$ as pseudo-lambda term where $f$ occurs in its own definition:
$$f = \ldots f \ldots f \ldots $$
First, we realize t... |
Some years ago my elder son and I developed a Plain English programming and development system in the interest of answering the following questions:
1. Can low-level programs (like compilers) be conveniently and efficiently written in high level languages (like English)?
2. Can natural languages be parsed in a ... |
Does $\mathsf{NSPACE}( f (n)) = \mathsf{coNSPACE}( f (n))$ hold for $ f(n) < \log (n) $? |
[Immerman–Szelepcsényi][1] theorem works under logarithmic reduction. Sublogarithmic space classes has different reductions. The TMs working within **sublogarithmic space cannot even record the the length of the input**. It has been shown that the space hierarchy for any sublogarithmic bound in **Ω(log log n)-- o(log ... |
As Yuval has pointed out there is not just one fixed-point operator. There are many of them. In other words, the equation for fixed-point theorem do not have a single answer. So you can't derive the operator from them.
It is like asking how people derive $(x,y)=(0,0)$ as a solution for $x=y$. They don't! The equati... |
As Yuval has pointed out there is not just one fixed-point operator. There are many of them. In other words, the equation for fixed-point theorem do not have a single answer. So you can't derive the operator from them.
It is like asking how people derive $(x,y)=(0,0)$ as a solution for $x=y$. They don't! The equati... |
|computability|logic|programming-languages|lambda-calculus| |
The are *[countably][1]* many computable functions:
Each computable function has at least one algorithm.
Each algorithm has a finite description using symbols from a finite set, e.g. finite binary strings using symbols $\{0,1\}$.
The number of finite binary strings denoted by $\{0,1\}^*$ is countable (i.e. the s... |
[Immerman–Szelepcsényi][1] theorem works under logarithmic reductions. Sublogarithmic space classes have different reductions. The TMs working within **sublogarithmic space cannot even record the the length of the input**. It has been shown that the space hierarchy for any sublogarithmic bound in **Ω(log log n)-- o(lo... |
Throughout this answer, we assume $f$ and $T$ are non-negative. Our proof works whenever $f = \Theta(g)$ for some monotone $g$. This includes your Mergesort example, in which $f=\Theta(n)$, and any function which has polynomial growth rate (or even $\Theta(n^a \log^b n)$).
Let's consider first the case that $f$ is m... |
null |
What are anonymous (lambda) functions? What is the formal definition of an anonymous function in a functional programming language?
In my simple terms, when I am programming in scheme/lisp I would say an anonymous (lambda) function is a function that is not bound to an identifier.
Is that all that you can say fo... |
anonymous lambda functions (functional programming) |
|lambda-calculus|functional-programming| |
One example I can think of off-hand is for path-finding algorithms in graph-theory. If we define a semiring with $+$ as $\min$ and $\cdot$ as $+$, then we can use matrix multiplication with the adjacency matrix to find all-pairs-shortest-path. This method is actually described in CLRS.
While this may seem only theo... |
I was reading the ADA 95 reference manual. I came across these two words in annexes
Normative and informative . I couldnt find the difference between those. Your help will be much appreciated.
|
Difference between Normative annexes and Informative annexes in ADA 95 |
|reference-request|programming-languages|books| |
"Normative" means something that has to be followed, part of the standard. "Informative" is explanations meant to be understood by mere human beings, and that might be ambiguous or inaccurate. It is _not_ to be relied on. Read it to understand, refer to the normative parts where it matters. |
One important problem in distributed file systems is to generate files from distributed blocks. The area of [Erasure code][1] from information theory and Algebra is used extensively in distributed fault tolerant file systems for example in [HDFS RAID][2] (Hadoop Based File System). Twitter and social network companies ... |
If your question is
>What are examples of groups, monoids, and rings in computation?
then one example I can think of off-hand is for path-finding algorithms in graph-theory. If we define a semiring with $+$ as $\min$ and $\cdot$ as $+$, then we can use matrix multiplication with the adjacency matrix to find all-pa... |
null |
In my opinion, that's all you can really say about them.
The idea is that in a higher-order language, a function is just another kind of value. The same way you can have (3+4) without an identifier in C, you can have (lambda (x) +(3 x))) without an identifier scheme.
The key here isn't that there's anything speci... |
We want to tile $m\times m$-square using two types of tiles: $1 \times 1$-square tile and $2 \times 2$-square tile such that every underlying square is covered without overlapping. Let us define a function $f(n)$ that gives the size of largest uniquely tillable square using $n$ $1\times 1$-squares and any number of $2 ... |
|logic|programming-languages|lambda-calculus|functional-programming| |
We want to tile $m\times m$-square using two types of tiles: $1 \times 1$-square tile and $2 \times 2$-square tile such that every underlying square is covered without overlapping. Let us define a function $f(n)$ that gives the size of largest uniquely tillable square using $n$ $1\times 1$-squares and any number of $2 ... |
Professor Tim Roughgarden from Stanford University while teaching a [MOOC][1] said that solutions to problems in the class NP must be polynomial in length. But the [wikipedia article][2] says that NP problems are decision problems. So what type of problems are basically in the class NP ? And is it unnecessary to say th... |
Is it necessary for NP problems to be decision problems? |
|algorithms|np|p-vs-np| |
I'm currently reading a book in algorithms and complexity. At the moment I'm, reading about computable and non-computable functions, and my book states that there are many more functions that are non-computable than computable, in fact the majority is non-computable it says. In some sense I can intuitively accept that ... |
|computability|turing-machines|combinatorics| |
{"OriginalQuestionIds":[9175],"Voters":[{"Id":683,"DisplayName":"Yuval Filmus"},{"Id":4249,"DisplayName":"Pål GD"},{"Id":157,"DisplayName":"Ran G."},{"Id":98,"DisplayName":"Raphael"}]} |
Indeed problems in NP are decision problems which output 0 or 1 for a given input string. Prof Roughgarden is referring to the fact the problems in NP have short polynomially bounded proof (in the input length) of membership that can be verified efficiently (by polynomial time algorithm). |
Indeed problems in NP are decision problems which output 0 or 1 for a given input string. Prof Roughgarden is referring to the fact that problems in NP have short polynomially bounded proof (in the input length) of membership that can be verified efficiently (by polynomial time algorithm). |
Tibor Jager and Jörg Schwenk show in [The Generic Hardness of Subset Membership Problems under the Factoring Assumption][1] that factoring reduces to distinguishing quadratic residues from numbers with Jacobi symbol 1, *for generic ring algorithms*. These are algorithms whose only "API" to integers are ring operations ... |
We have to show that
$\qquad (E_1 + E_2).F^\omega = E_1.(F^\omega) + E_2.(F^\omega)$.
We have do to some preparation. $E_1, E_2$ and $F$ are regular expressions, so they have (deterministic) finite automata $A_1, A_2, A_F$. It is easy to see that we can construct NBA for the left and right hand side from those, r... |
Distributivity of $\omega$-regular expressions |
The idea is to decide nondeterministically at the beginning how much the word is cycled, and have a copy of the automaton for every case. In terms of the automaton, that means that we guess in which state $D$ would have been after consuming a word's prefix (which is a suffix of our input), and start in that state.
N... |
In the lambda calculus, _all_ functions (terms) are anonymous. This is an essential property of the lambda calculus: you can compose complex functions from simpler ones without giving them names.
In programming languages, it is in most cases desirable to give names to functions, because this is the way we think and ... |
Tibor Jager and Jörg Schwenk show in [The Generic Hardness of Subset Membership Problems under the Factoring Assumption][1] that factoring reduces to distinguishing quadratic residues from numbers with Jacobi symbol 1, *for generic ring algorithms*. These are algorithms whose only "API" to integers are ring operations ... |
null |
I've seen a reduction that's done by adding another vertex to the graph and creating a path through that vertex.
Why do I need to add a vertex? Cant I just remove an edge? Lets say the graph with the HamCycle is G,s,t when removing the edge between s and t dont I get a path the goes through all the vertexes that's q... |
HamCycle to HamPath reduction |
|reductions| |
(aaaaa)^n aa (aaaaa)^n : so contains aa or 5a's each side plus aa.
I thought this is alphabet = only a , contains at least 2a in middle plus
multiples of 5 as on each side.
looks like infinite many states required -> not regular but any other opinion ?
|
Regular language ? or not ? |
|automata| |
Is the language $\lbrace (aaaaa)^n aa (aaaaa)^n \mid n \in \mathbb{N} \rbrace$ regular? It looks like I need infinitely many states so it is not regular.
|
Is $(aaaaa)^n aa (aaaaa)^n$ a regular language? |
The language consists of those strings that contain $5 n + 2 + 5 n = 10 n + 2$ symbols $a$ for some $n \in \mathbb{N}$, i.e.,
$$\lbrace(aaaaa)^n aa (aaaaa)^n \mid n \in \mathbb{N}\rbrace =
\lbrace (aaaaaaaaaa)^n aa \mid n \in \mathbb{N} \rbrace.$$
It is regular because it is accepted by the automaton which has twelv... |
I need some help with deciding if a given language is regular, context-free or not context-free.
Lets' say I have the following languages over the alphabet $\mathcal{A} = \{a,b,c,d\}$:
$$ \begin{align}
L_1 &= \{ w \in \mathcal{A}^* \mid \text{\(\#a(w)\) is even and \(\#b(w) = 1 \mathrel{\mathrm{mod}} 3\) and \... |
Deciding whether a Language is Context-free/Regular/Non Context-Free |
null |
Because not necessarily the Hamiltonian cycle traverses the edge between $s$ and $t$ (it can visit both nodes without traversing the edge between them). |
|formal-languages|regular-languages| |
First of all I think that the direction of the reduction of your question is from Hampath to Hamcycle (you prove the NP-hardness of Hamcycle reducing the NP-complete problem Hampath to it).
Now given an instance of Hampath: $G,s,t$:
1) there is an edge between $s$ and $t$<br>
2) there is not an edge between $s$... |
|complexity-theory|np-complete|reductions| |
The set of all words over some finite alphabet together with concatenation forms the free monoid $(\Sigma^*, \cdot)$. Therefore, the whole field of formal language can be viewed through the algebraic lense, and it is sometimes taught like this.
In return, considerations on formal languages have yielded the [Earley p... |
|reference-request|discrete-mathematics|database-theory|applied-theory|group-theory| |
First of all I think that the direction of the reduction of your question is from Hampath to Hamcycle (you prove the NP-hardness of Hamcycle reducing the NP-complete problem Hampath to it).
Now given an instance of Hampath: $G,s,t$:
1) there is an edge between $s$ and $t$<br>
2) there is not an edge between $s$... |
In many implementations of depth-first search that I saw (for example: [here](http://ramos.elo.utfsm.cl/~lsb/elo320/aplicaciones/aplicaciones/CS460AlgorithmsandComplexity/lecture9/COMP460%20Algorithms%20and%20Complexity%20Lecture%209.htm)), the code distinguish between a grey vertex (discovered, but not all of its neig... |
The purpose of grey node in graph depth-first search |
|graphs|graph-traversal| |
null |
Consider a network of time servers known to be synchronous, $\theta = \{A, B, C\}$, and a client machine $P$.
Let $T_{XY}$ be the one way time of flight from machine $X$ to machine $Y$, with the possibility that $T_{XY}\neq T_{YX}$.
Let $\Delta_{XY} = |T_{XY} - T_{YX}|$ be the measure of the asymmetry between mac... |
If I have a system of N polynomial equations with N unknowns in GF(2):
* What are some good methods to solve them?
* What are some software packages or libraries that implement this?
* What's the highest value of N that can be reasonable solved?
Now, my root interest isn't GF, it's crypto. Here's my reasoning:... |
Complexity of GF(2) and applications to cryptography |
|algorithms|cryptography|discrete-mathematics|sat-solvers| |
What are the fastest known algorithms for general convex optimisation under linear inequality constraints? |
Convex optimisation under linear inequality constraints |
|algorithms|optimization| |
Grey vertex states that you have visited that node and moved on to one of its neighbors in some order, but there might be more neighboring vertices to that node. It while be useful while backtracking for exploring unvisited vertices.
Let's say **Vertex A has two neighbors B and C and B has one neighbor D**.
s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.