instruction stringlengths 0 29.8k ⌀ |
|---|
null |
I'm assuming you want a data structure storing a set of points where you can:
- Insert a new point
- Get the list of cells containing a point (this is your query).
You can do this by storing the points in a 2D [range tree][1]. These allow you, for any given orthogonal range, to test if they contain at least one po... |
i can't seem to find much info on the following question:
*how (if at all) is the fixing of names to values (by binding or assignment) possible in a purely functional system like the lambda calculus?*
i've seen examples of this being done in haskell, lisp etc. by using the 'let' or '=' operators.
to me it alway... |
(how) is assignment or binding possible in purely functional languages? |
|lambda-calculus|functional-programming|variable-binding| |
null |
Given a dense an undirected graph $G=(V,E)$ where I have a large amount of vertices and $|E|\in O(|V|^2)$ many edges, I would like to check whether it contains a cross/parallel (unrelated) edge pair. These are $2$ edges $\left(v_1, v_2\right)$ and $\left(v_3, v_4\right)$ such that for any $i<j$ (excluding $i=1,j=2$ and... |
null |
I need to implement an algorithm to create schedules for round-robin tournaments (where each team faces each other team exactly once), but with the constraint that up to 2 teams – that may play in different leagues – might share the same field on the same time slot of the week, so they must be never be scheduled to pla... |
Round-robin tournament scheduling, with teams that may share their home field |
|algorithms|scheduling| |
null |
The lambda calculus has names for the parameter (bound variable) to a lambda abstraction. That is the only mechanism or introducing names. Apart from that, there are no names in the lambda calculus. Notice that there is no assignment within the lambda calculus.
There is nothing non-functional being hidden here.
... |
Based on [your clarification](https://cs.stackexchange.com/questions/162665/calculating-cells-encompassing-points-in-a-grid#comment339783_162665) to the question, it appears the task is as follows: you are given a list of all points; the algorithm should process this list and then output the list of all cells that cont... |
This sounds like a operations research problem. I suggest using a standard hammer for that kind of problem: use a SAT solver or ILP solver. For instance, you might have a boolean variable for each tuple of team/location/time, which is true if that team plays at that location at that time; then use boolean/linear cons... |
I've been reading up on scheduling problems and the class of them that is NP-complete. Specifically, [this][1] is a foundational text on such problems, but the reductions are not clear to me. Can someone help identify the reduction from 3-partition, if I am trying to show the problem is NP-hard when I am scheduling tas... |
null |
|reductions|scheduling| |
I suspect you're imagining $\text{let } x = E \text{ in } E'$ as describing a sequence of steps: take the thing described by $E$ and put it in the box labeled $x$, then proceed to the thing labeled $E'$. It will seem less imperative if you take a less imperative view of it. Real functional languages are of necessity co... |
null |
null |
I need to implement an algorithm to create schedules for round-robin tournaments (where each team faces each other team exactly once), but with the constraint that up to 2 teams – that may play in different leagues – might share the same field on the same time slot of the week, so they must never be scheduled to play a... |
I need to implement an algorithm to create schedules for round-robin tournaments (where each team faces each other team exactly once), but with the constraint that up to 2 teams – that may play in different leagues – might share the same field on the same time slot of the week, so they must never be scheduled to play a... |
null |
{"Voters":[{"Id":6553,"DisplayName":"Pseudonym"}],"DeleteType":1} |
{"Voters":[{"Id":6553,"DisplayName":"Pseudonym"}]} |
Wikipedia states that the time complexity of the [General Number Field Sieve (GNFS)][1] is
$$\exp\left( \left(\sqrt[3]{\frac{64}{9}} + o(1)\right)(\log N)^{\frac{1}{3}}(\log \log N)^{\frac{2}{3}}\right),$$
where $N$ is the number to be factored.
The same site also mentions that [quasi-polynomial time][2] is
$$\mb... |
|time-complexity|number-theory|factoring| |
How do I show that a (possibly partial) function is computable iff its graph is recursively enumerable? |
function is computable iff its graph is recursively enumerable? |
|computability|semi-decidability|recursively-enumerable| |
null |
A claw is another name for the complete bipartite graph $K_{1,3}$. A *claw-free* graph is a graph that does not have a claw as an induced subgraph.
I know, in general, induced subgraph isomorphism is an NP-complete problem. However, the situation may be different for certain special induced-subgraphs. For example, ... |
Algorithmic Complexity of Recognizing Claw-Free Graphs |
|complexity-theory|graphs| |
Let $H=\left(V_H, E_H\right)$ and $G=(V, E)$ be graphs. A *subgraph isomorphism* from $H$ to $G$ is a function $f: V_H \rightarrow V$ such that if $(u, v) \in E_H$, then $(f(u), f(v)) \in E$. $f$ is an *induced subgraph isomorphism* if in addition if $(u, v) \notin E_H$, then $(f(u), f(v)) \notin E$.
A claw is an... |
Let $H=\left(V_H, E_H\right)$ and $G=(V, E)$ be graphs. A *subgraph isomorphism* from $H$ to $G$ is a function $f: V_H \rightarrow V$ such that if $(u, v) \in E_H$, then $(f(u), f(v)) \in E$. $f$ is an *induced subgraph isomorphism* if in addition if $(u, v) \notin E_H$, then $(f(u), f(v)) \notin E$.
A *claw* is ... |
I believe that the answer the author has in mind is something more in the line of binary long division, which can be "efficiently" implemented with shifts, subtractions and comparisons in $O(W)$ steps where $W$ is the machine word length in bits.
Notice that using bit shifts, which could be interpreted as a way to r... |
A graph is, as you say, claw-free if and only if it does not contain $K_{1,3}$ as an induced subgraph.
This gives rise to the trivial $n^4$ algorithm: for every set of four vertices, is the degrees of the induced subgraph $3,1,1,1$? |
I'm assuming you want a data structure storing a set of points where you can:
- Insert a new point
- Get the list of all cells which contain at least one point (this is your query).
You can do this by storing the points in a 2D [range tree][1]. These allow you, for any given orthogonal range, to test if they conta... |
I'm writing a program which uses an undirected graph to represent certain social connections, and I'm trying to check whether or not it contains a specific induced subgraph.
Given a dense an undirected graph $G=(V,E)$ where I have a large amount of vertices and $|E|\in O(|V|^2)$ many edges, I would like to check wh... |
Finding an induced $2K_2$ in subcubic time |
I believe that the answer the author has in mind is something more in the line of binary long division, which can be "efficiently" implemented with shifts, subtractions and comparisons in $O(W)$ steps where $W$ is the machine word length in bits.
Notice that using bit shifts, which could be interpreted as a way to r... |
In the paper "Computability by Probabilistic Machines" by K. de Leeuw, E. F. Moore, C. E. Shannon, and N. Shapiro (in Claude E. Shannon: Collected Papers , IEEE, 1993, pp.742-771), a **sequence** (NOT a set) $S=(s_1,s_2,\ldots)$ is 1-computable if (I state it differently from the paper but equivalently) there is a Turi... |
Computability = Enumerating a sequence in the particular order? |
|computability|terminology|history|recursively-enumerable| |
On a table there are N stacks (numbered 1 to N). Stack i contains i tokens (1≤i≤N). During a move, a set of stacks can be chosen and the same number of chips can be drawn from each stack that is part of the chosen set.
My approach would be to split the stacks in half, and removing n/2 tokens from the second half. No... |
On a table there are N stacks. Stack i contains i tokens. During a move, a set of stacks can be chosen and the same number of tokens can be taken |
|recurrence-relation|greedy-algorithms| |
On a table there are N stacks (numbered 1 to N). Stack i contains i tokens (1≤i≤N). During a move, a set of stacks can be chosen and the same number of chips can be drawn from each stack that is part of the chosen set. What is the minimum number of moves to make all stacks empty?
My approach would be to split the st... |
On a table there are N stacks. Stack i contains i tokens. Minimum number of moves to make all stacks empty |
On a table there are N stacks (numbered 1 to N). Stack i contains i tokens (1≤i≤N). During a move, a set of stacks can be chosen and the same number of chips can be drawn from each stack that is part of the chosen set. What is the minimum number of moves to make all stacks empty?
For example if N=3, the answer is 2. O... |
OS also adheres to the DRY principle, reusing code that has already been implemented by developers. For example, the kernel could open/close/write to the log file, allowing it to reuse the syscall implementation rather than re-implementing it wherever it is needed.
"Write the core implementation once, reuse it when ... |
null |
On a table there are $N$ stacks (numbered $1$ to $N$). Stack $i$ contains $i$ tokens ($1 \leq i \leq N$). During a move, a set of stacks can be chosen and the same number of chips can be drawn from each stack that is part of the chosen set. What is the minimum number of moves to make all stacks empty?
For example if $... |
On a table there are $N$ stacks. Stack $i$ contains $i$ tokens. Minimum number of moves to make all stacks empty |
Your estimation of the number of transistors allocated to each function seems way off to me.
[![enter image description here][1]][1]
As you can see from the schematic, the 8008 has three 8-bit registers, two pointer registers, 7x8-bit registers for accumulators and scratchpad memory and 8x14-bit address stack reg... |
I'm writing a program which uses an undirected graph to represent certain social connections, and I'm trying to check whether or not it's contains a specific induced subgraph.
Given a dense an undirected graph $G=(V,E)$ where I have a large amount of vertices and $|E|\in O(|V|^2)$ many edges, I would like to check ... |
I'm going to consider $n=2^k$ for some positive integer $k$ since this will result in sharp bounds. You can get the same asymptotic bounds for arbitrary $n$ with the same arguments.
Consider a strategy that uses at most $k-1$ moves.
This means that there are most $2^{k-1}$ stacks such that any pair of such stacks ... |
If you have one of:
1. A machine that takes an index $i$ and definitely terminates with $s_i$ as a result
2. A machine that takes an index $i$ and a value $s$ and definitely terminates, indicating whether $s$ is the $i$th value of the sequence
then you can write out the sequence in order by simulating one of the... |
null |
null |
I'm going to consider $n=2^k$ for some positive integer $k$ since this will result in simpler bounds. The same strategy extends to arbitrary $n$.
Consider a strategy that uses at most $k-1$ moves.
This means that there are most $2^{k-1}$ stacks such that any pair of such stacks are affected by different moves.
Si... |
The state diagram for the initial part of this turing machine given as:
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/Q1mZG.png
Here, we are basically traversing through the input tape, changing occurence of 'a' to X1, and 'c' to X2. After that we go back in the left direction u... |
Turing machine for a^n b^m c^n d^m |
|turing-machines|finite-automata|context-free|recursively-enumerable| |
The state diagram for the initial part of this turing machine given as:
[![enter image description here][1]][1]
Here, we are basically traversing through the input tape, changing occurence of 'a' to X1, and 'c' to X2. After that we go back in the left direction until we find X1 again, and then we repeat the pr... |
Let $G$ be our graph. For each vertex $v \in V(G)$, let $H_v$ be the complement of the subgraph consisting of all vertices adjacent to $v$. We find an induced $K_{1,3}$ in $G$ if and only if there is any vertex $v$ for which $H_v$ contains a triangle.
Of course, there is the trivial $O(n^3)$ algorithm for testing if... |
Here is an $O(n^3)$ algorithm. Go through every edge $xy$ of our graph $G$; in linear time, we will test whether $xy$ can be the edge of a claw in $G$.
For this, we count vertices of two types:
1. Vertices adjacent to $x$, but not $y$;
2. Vertices adjacent to $y$, but not $x$.
We find two vertices $z_1, z... |
Let $G$ be our graph. For each vertex $v \in V(G)$, let $H_v$ be the complement of the subgraph consisting of all vertices adjacent to $v$. We find an induced $K_{1,3}$ in $G$ if and only if there is any vertex $v$ for which $H_v$ contains a triangle.
Of course, there is the trivial $O(n^3)$ algorithm for testing if... |
Let $k$ be the smaller integer such that $2^k > n$.
**Any solution must use at least $k$ moves**
Suppose towards a contradiction that there exists a winning strategy using at most $k-1$ moves $m_1, m_2, \dots$.
Label each stack $i$ with the set $M(i)$ of moves $m_j$ that involve $i$ and notice that no label ca... |
Let $k$ be the smallest integer such that $2^k > n$.
**Any solution must use at least $k$ moves**
Suppose towards a contradiction that there exists a winning strategy using at most $k-1$ moves $m_1, m_2, \dots$.
Label each stack $i$ with the set $M(i)$ of moves $m_j$ that involve $i$ and notice that no label c... |
On a table there are $n$ stacks (numbered $1$ to $n$). Stack $i$ contains $i$ tokens ($1 \leq i \leq n$). During a move, a set of stacks can be chosen and the same number of chips can be drawn from each stack that is part of the chosen set. What is the minimum number of moves to make all stacks empty?
For example if $... |
null |
Let $G$ be our graph. For each vertex $v \in V(G)$, let $H_v$ be the complement of the subgraph consisting of all vertices adjacent to $v$. We find an induced $K_{1,3}$ in $G$ if and only if there is any vertex $v$ for which $H_v$ contains a triangle.
Of course, there is the trivial $O(n^3)$ algorithm for testing if... |
Let $G$ be our graph. For each vertex $v \in V(G)$, let $H_v$ be the complement of the subgraph consisting of all vertices adjacent to $v$. We find an induced $K_{1,3}$ in $G$ if and only if there is any vertex $v$ for which $H_v$ contains a triangle.
Of course, there is the trivial $O(n^3)$ algorithm for testing if... |
I came across the online course [Design And Analysis Of Algorithms](https://ocw.mit.edu/courses/6-046j-design-and-analysis-of-algorithms-spring-2015/pages/assignments/) and the assignments have several questions that ask you to design algorithms, but you are not asked to implement them in code. I think I would have a d... |
Implementing algorithms from online courses in code to solidify understanding |
|coding-theory| |
A decycling set in a graph is a subset of its vertices, deletion of which induces a forest.
What is a tight upper bound on the number of decycling sets which induce a tree(NOT a forest) in a connected 3-regular planar graph ?
The illustration below shows such a tree in a 3-regular planar graph. The vertices tha... |
Number of decycling sets in a 3-regular planar graph |
|graphs|planar-graphs| |
null |
Consider the problem to minimize the checkout price of a shopping basket in the presence of some discount rules:
There are $n \gt 0$ distinct products in our shopping basket. Each product is associated with a price $price_i \geq 0$ and a quantity $quantity_i \gt 0$. Without applying any discounts, the checkout price... |
Is there an efficient algorithm for this ecommerce optimization problem? |
|algorithms|np-complete|np-hard|combinatorics| |
Let's say I have a set of three columns - column1, column2, column3 - and I need to generate rows of these three columns. I want those rows to be unique. Each column has a function. The function allows to generate a single value from 1 to 10 - basically I need to generate unique sets of 3 items.
Right now I generate... |
fast estimation of the amount of unique combinations |
|algorithms|combinatorics|python| |
Consider the problem of minimizing the checkout price of a shopping basket in the presence of some discount rules:
There are $n \gt 0$ distinct products in our shopping basket. Each product is associated with a price $price_i \geq 0$ and a quantity $quantity_i \gt 0$. Without applying any discounts, the checkout pri... |
If you don’t have a multiplication operation, you can implement for example a 64x64 bit product with 63 additions, in constant time. So your asymptotic behaviour doesn’t change. |
For execution time, you just measure with problems of different sizes. Take a problem of size n big enough so it takes ten seconds to solve, then solve problems of size 1.1n, 1.2n and see how the time behaves.
Correctness: That’s a problem you will always have, in every programming job you do, when there is nobody ... |
[This 2015 paper](https://www.cs.princeton.edu/~hy2/files/graph-cr.pdf) by Williams et al. considers **induced** subgraphs and shows how to find $C_4$ and co-$C_4$ in a graph $G$ time $O(\min\{n^\omega, m^{\frac{4\omega-1}{2\omega+1}}\})$, where $n$, $m$, and $\omega$ are the number of vertices and edges of $G$, and t... |
[This 2015 paper](https://www.cs.princeton.edu/~hy2/files/graph-cr.pdf) by Williams et al. considers **induced** subgraphs and shows how to find $C_4$ and co-$C_4$ in a graph $G$ time $O(\min\{n^\omega, m^{\frac{4\omega-1}{2\omega+1}}\})$, where $n$, $m$ are the number of vertices and edges of $G$, respectively, and $... |
A graph is, as you say, claw-free if and only if it does not contain $K_{1,3}$ as an induced subgraph.
This gives rise to the trivial $n^4$ algorithm: for every set of four vertices, is the degrees of the induced subgraph $3,1,1,1$?
Steven, in another thread, points to a paper by [Williams, Wang, Williams, and Yu... |
null |
[This 2015 paper](https://www.cs.princeton.edu/~hy2/files/graph-cr.pdf) by Williams et al. considers **induced** subgraphs and shows how to find $C_4$ and co-$C_4$ in a graph $G$ time $O(\min\{n^\omega, m^{\frac{4\omega-1}{2\omega+1}}\})$, where $n$, $m$ are the number of vertices and edges of $G$, respectively, and $... |
A decycling set in a graph is a subset of its vertices, deletion of which induces a forest.
What is a tight upper bound on the number of decycling sets which induce a tree(NOT a forest) in a connected 3-regular planar graph ?
The illustration below shows such a tree in a 3-regular planar graph. The vertices tha... |
null |
*Defintitions*:
A graph is said to be **r-regular** if every of its vertex has a degree $r$. A graph is **planar** if it can be drawn in a plane without any of its edges intersecting each other except at their endpoints. A graph is **connected** if there exists at least one path between every pair of its vertices. A *... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.