instruction stringlengths 0 29.8k ⌀ |
|---|
Given a collection of sets $C=\\{S_1, S_2, \ldots, S_n\\}$ with each $S\in C$ holding some integers, I would like to find a pair $\\{x,y\\}, x\ne y$ such that $\{x,y\}\subset S$ for the highest number of $S\in C$ among all such pairs.
Is there an efficient algorithm to find such a pair? |
Can we efficiently find the most common pair in a set of sets? |
|algorithms|sets| |
null |
We have a binary raster image in which we consider the white blobs (connected components). We define a distance between two blobs to be the length of the shortest path between any two respective pixels (topological distance), or alternatively the shortest Euclidean distance between two pixels. In general the two defini... |
Minimum spanning tree between blobs |
|computational-geometry|minimum-spanning-tree|digital-image-processing| |
Given a collection of sets $C=\{S_1, S_2, \ldots, S_n\}$ with each $S\in C$ holding some integers, I would like to find a pair $\{x,y\}, x\ne y$ such that $\{x,y\}\subset S$ for the highest number of $S\in C$ among all such pairs.
Is there an efficient algorithm to find such a pair? |
This one is regarding $\mathsf{FPT}$ time algorithm.
Suppose an algorithm has time complexity of: $\Theta((\log n)^k \cdot n^{O(1)})$.
Is it an $\mathsf{FPT}$ time algorithm in parameter $k$?
Well obviously no since the time complexity is not of the form $\Theta(f(k) \cdot n^{O(1)})$. This is what most of pe... |
null |
Reading the [manual][1] for GNU grep, the special characters (with -E option) are `.?*+{|()[\^$`.
This is a somewhat pedantic question, but why are `]` and `}` omitted? In particular it says in section 3.1 "An unmatched `)` just matches itself", which is true for `]` and `}` as well.
I sense that it has to do... |
Why are ] and } not considered special characters? |
|regular-expressions|syntax| |
Reading the [manual][1] for GNU grep, the special characters (with -E option) are `.?*+{|()[\^$`.
This is a somewhat pedantic question, but why are `]` and `}` omitted? In particular it says in section 3.1 "An unmatched `)` just matches itself", which is true for `]` and `}` as well.
I think it is just a slig... |
null |
As a general idea, maybe a 'proof' of a greedy algorithm as applied to a problem where the failure case is not immediately obvious?
A classic example (used for introducing Ford-Fulkerson) would be always taking the s-t path with max flow (without creating the residual graph), with some hand waving on how another "op... |
null |
How to provide a reduction from 3SAT to domatic number problem.
Domatic number problem: Given a graph $G = (V, E)$ and an integer $k$, can we partition $V $ into at least k disjoint sets of vertices, such that each set is a dominating set of $G$?
I have made many attempts, but still have no clue. |
How to provide a reduction from 3SAT to domatic number problem |
|complexity-theory|computability|np-complete|np|polynomial-time-reductions| |
null |
null |
Induction often yields great wrong proofs because there are many things which can fail:
- The induction base $P(0)$ can be false, or it may be missing at all and hence the rest of the induction is based on a false assumption. If the induction base is false, everything else is an *ex falso quodlibet*.
- The inductio... |
From my understanding, something like Linux is very geared towards C programs, with things like `libc`. What I'm wondering is, even in Java, you have arguments to your "main" program. The same thing occurs in C. From my understanding, this is just some data the kernel puts on an anonymous page for the stack of the proc... |
What does it take to support a programming language on an OS? |
|programming-languages|operating-systems|compilers| |
*(Apologies if this kind of post is not allowed).*
I remember seeing a list of False Proofs when I was taking Discrete Maths and I found it to be very interesting and also helpful.
I'm going to be a TA for an algorithms course next semester (this is a theoretical sophomore/junior level algorithms course not lik... |
The fourth edition of 'Introduction to Algorithms' defines algorithmic recurrences on [page 77](https://books.google.co.nz/books?id=drZNEAAAQBAJ&pg=PA77&lpg=PA77&dq=%22the+running+time+of+the+algorithm+may+not+be+defined%22&source=bl&ots=pcRh0wi83c&sig=ACfU3U2nPuQ-E89ihAh8O6S0sEdYvLVYLg&hl=en&sa=X&ved=2ahUKEwifxMuWyLX_... |
Justification for the properties of algorithmic recurrences in 'Introduction to Algorithms' (CLRS, 4e) |
|algorithms|algorithm-analysis|recurrence-relation|recursion|divide-and-conquer| |
The fourth edition of 'Introduction to Algorithms' defines algorithmic recurrences on [page 77](https://books.google.co.nz/books?id=drZNEAAAQBAJ&pg=PA77&lpg=PA77&dq=%22the+running+time+of+the+algorithm+may+not+be+defined%22&source=bl&ots=pcRh0wi83c&sig=ACfU3U2nPuQ-E89ihAh8O6S0sEdYvLVYLg&hl=en&sa=X&ved=2ahUKEwifxMuWyLX_... |
Consider the $k$-center problem where we are given an undirected, complete graph $G=(V, E)$, with a distance $d(u, v) \geq 0$ for each pair $u, v \in V$. Furthermore, we assume that the triangle inequality holds: for each triple $u, v, w \in V$ it is the case that $d(u, w) \leq d(u, v)+d(v+w)$. The goal is to find $k$ ... |
Induction often yields great wrong proofs because there are many things which can fail:
- The induction base $P(0)$ can be false, or it may be missing at all and hence the rest of the induction is based on a false assumption. If the induction base is false, everything else is an *ex falso quodlibet*.
- The inductio... |
This one is regarding $\mathsf{FPT}$ time algorithm.
Suppose an algorithm has time complexity of: $O((\log n)^k \cdot n^{O(1)})$.
Is it an $\mathsf{FPT}$ time algorithm in parameter $k$?
Well obviously no since the time complexity is not of the form $O(f(k) \cdot n^{O(1)})$. This is what most of people think... |
Induction often yields great wrong proofs because there are many things which can fail:
- The induction base $P(0)$ can be false, or it may be missing at all and hence the rest of the induction is based on a false assumption. If the induction base is false, everything else is an *ex falso quodlibet*.
- The inductio... |
I am trying to solve problem in leetcode:
https://leetcode.com/problems/redundant-connection/description/
*finding redundant connection in undirected graph
And now I am writing a solution, inpired by Kruskal's algorithm:
https://en.wikipedia.org/wiki/Disjoint-set_data_structure#/media/File:UnionFindKruskalDemo.gi... |
Creative solving of searching redundant connection in graph |
|algorithms|graphs|data-structures| |
Induction often yields great wrong proofs because there are many things which can fail:
- The induction base $P(0)$ can be false, or it may be missing at all and hence the rest of the induction is based on a false assumption. If the induction base is false, everything else is an *ex falso quodlibet*.
- The inductio... |
I am trying to solve problem in leetcode:
https://leetcode.com/problems/redundant-connection/description/
*finding redundant connection in undirected graph
And now I am writing a solution, inpired by Kruskal's algorithm:
https://en.wikipedia.org/wiki/Disjoint-set_data_structure#/media/File:UnionFindKruskalDemo.gi... |
null |
The 1st property is referring to the time needed by the recursive algorithm to solve a problem instance with size $n<n_0$. Under this case the algorithm can directly solve the problem, i.e. no recursion needed. They are then trying to show that the time needed for this must be constant, because the size of the instance... |
The 1st property is referring to the time needed by the recursive algorithm to solve a problem instance with size $n<n_0$. Under this case the algorithm can directly solve the problem, i.e. no recursion needed. They are then trying to show that the time needed for this must be constant, because the size of the instance... |
Disclaimer: I'm studying for an exam, but I don't have to hand in anything.
I have the state transition diagram of the FSM and its states encoding:
[![enter image description here][1]][1]
I want to find the Sum-Of-Products Boolean expression of *S<sup>1</sup><sub>0</sub>* , *S<sup>1</sup><sub>1</sub>* and oup... |
SOP Boolean expression of state variable and output of a Moore FSM |
|computer-architecture|logic|digital-circuits|combinatory-logic|algebra| |
This step is incomplete:
> sets[el].push(edges[i][1]);
When you add edge $(2,3)$, only $3$ is getting added to the existing set $\{2,8\}$. And, only $2$ is getting added to existing set $\{3,7,9, \dotsc\}$.
You should also add all the elements of the set $\{2,8\}$ to $\{3,7,9, \dotsc\}$ and vice-versa. Note t... |
This step is incomplete:
> sets[el].push(edges[i][1]);
For edge $(2,3)$, only $3$ is getting added to the existing set $\{2,8\}$. And, only $2$ is getting added to existing set $\{3,7,9, \dotsc\}$.
You should also add all the elements of the set $\{2,8\}$ to $\{3,7,9, \dotsc\}$ and vice-versa. Note that you h... |
Merge-sort can be done in linear time!
Indeed, the time complexity to sort a list or array of length $n$ verifies$^{(1)}$:
$$T(n) = T\left(\left\lfloor\frac{n}2\right\rfloor\right) + T\left(\left\lceil\frac{n}2\right\rceil\right)+ \Theta(n)$$
Let us prove by induction that $T(n) = \Theta(n)$:
- the base case i... |
I remember seeing a list of False Proofs when I was taking Discrete Maths and I found it to be very interesting and also helpful.
I'm going to be a TA for an algorithms course next semester (this is a theoretical sophomore/junior level algorithms course not like a data structures one) and I want to compile a bigge... |
<sub>**Disclaimer:** I'm studying for an exam, but I don't have to hand in anything.</sub>
---
I have the state transition diagram of the FSM and its states encoding:
---
[![state transition diagram][1]][1]
---
I want to find the **sum-of-products** (SOP) Boolean expression of $S_0^1$, $S_1^1$ and out... |
|computer-architecture|logic|boolean-algebra|digital-circuits| |
null |
or wich phenomena have behavior that can be measured and described as a function between natural numbers but seem to be hard to simulate with digital hardware when the starting conditions are given.
|
which phenomena got used to calculate a function that was never computed by digital hardware |
|computability| |
I remember seeing a list of False Proofs when I was taking Discrete Maths and I found it to be very interesting and also helpful.
I'm going to be a TA for an algorithms course next semester (this is a theoretical sophomore/junior level algorithms course not like a data structures one) and I want to compile a bigge... |
I have read the definition of treewidth/tree-decomposition both in Wikipedia and in here:
https://medium.com/@karlrombauts/treewidth-how-all-graphs-are-trees-in-disguise-ec699b69e2fb
I'm finding something hard to understand why the treewidth of a tree is $1$. By the definition of tree-decomposition, I may select to... |
Clarifications about tree-width definition |
|graphs|terminology|trees|treewidth| |
If there is at least one $n<n_0$ such that there is a legal input, then obviously the running time can be bracketed as
$$c_{\min}\le T(n)\le c_{\max}$$ where the minimum and maximum are taken over all legal inputs (for all $n<n_0$).
Obviously, the lower bound is itself bounded by the time for an empty function, l... |
If there is at least one $n<n_0$ such that there is a legal input, then obviously the running time can be bracketed as
$$c_{\min}\le T(n)\le c_{\max}$$ where the minimum and maximum are taken over all legal inputs (for all $n<n_0$).
Obviously, the lower bound is itself bounded by the time for an empty function, l... |
I came across the following question:
Given two context-free languages $L_1$ and $L_2$ is it decidable whether $L_1 - L_2 = \emptyset$ ?
The problem $All_{CFG}$ that states:
Given a CFG $G$ then $L(G) = Σ^*$ is known to be undecidable
So I thought to fix $L_2$ to be $Σ^*$ and allow $L_1$ to be any context-... |
Reformulating Decidability Problems |
|context-free|undecidability|correctness-proof| |
Your approach is correct.
------
> Given two context-free languages $L_1$ and $L_2$ is it decidable whether $L_1 - L_2 = \emptyset$ ?
It is understood the $L_1$ is given as $L(G_1)$ where $G_1$ is a given context-free grammar. $L_2$ is given as $L(G_2)$ where $G_2$ is a context-free grammar.
This convention... |
I came across the following question:
> Given two context-free languages $L_1$ and $L_2$ is it decidable whether $L_1 - L_2 = \emptyset$ ?
The problem $ALL_{\text{CFG}}$ that states:
Given a CFG $G$ then $L(G) = Σ^*$ is known to be undecidable.
So I thought to fix $L_2$ to be $Σ^*$ and allow $L_1$ to be an... |
Reformulating the Given Conditions in Decidability Problems |
Let the vertices of the graph G be the numbers 1, 2, ..., 100, and two (different) vertices be adjacent if and only if at least one of **2, 3, or 5 is a common divisor** of the respective numbers. Determine *χ(G)*, the chromatic number of the graph G.
I tried to solve and got that all even numbers i.e 2,3,4,...,100 ... |
Let the vertices of the graph G be the numbers 1, 2, ..., 100, a. Determine χ(G), the chromatic number of the graph G |
|graphs|discrete-mathematics| |
Let the vertices of the graph G be the numbers 1, 2, ..., 100, and two (different) vertices be adjacent if and only if at least one of **2, 3, or 5 is a common divisor** of the respective numbers. Determine *χ(G)*, the chromatic number of the graph G.
I tried to solve and got that all even numbers i.e 2,4,6,...,100 ... |
Hint 1: Show that the graph is $50$-partite.
Hint 2: Each partite set contains exactly two elements. |
Hint 1:
>! Show that the graph is $50$-partite.
Hint 2:
>!Each partite set contains exactly two elements.
Full Solution:
>!For colors $c_1,\dotsc,c_{50}$, assign color $c_i$ to numbers $2i-1$ and $2i$. Note that no two consecutive numbers can have a common divisor other than $1$. |
null |
I'm glossing over a few (lots of) details, but the following is essentially what happens when you run a program:
1. The operating system breaks off a chunk of memory for the program to run in. The binary code is copied into part of that memory (possibly a segment marked as read-only by non-OS processes). Another p... |
null |
Maybe not exactly what you're looking for, but the Monty Hall problem is famously counterintuitive.
There are three doors. One conceals a car, and the other two goats. You select one door. The gameshow host chooses opens a different demonstrates that it has a goat. By changing your choice to the other closed door, y... |
Your approach is correct.
------
> Given two context-free languages $L_1$ and $L_2$ is it decidable whether $L_1 - L_2 = \emptyset$ ?
It is understood the $L_1$ is given as $L(G_1)$ where $G_1$ is a given context-free grammar. $L_2$ is given as $L(G_2)$ where $G_2$ is a context-free grammar.
This convention... |
SMT (satisfiablity-modulo-theories) solvers can provide an (almost-) push-button solution for at least a subset of such problems, especially for those that perform machine-arithmetic, floats, arrays, etc., where efficient decision procedures exist.
There are several Haskell libraries built on-top-of SMT solvers to a... |
Your approach is correct.
------
> Given two context-free languages $L_1$ and $L_2$ is it decidable whether $L_1 - L_2 = \emptyset$ ?
It is understood the $L_1$ is given as $L(G_1)$ where $G_1$ is a given context-free grammar. $L_2$ is given as $L(G_2)$ where $G_2$ is a context-free grammar.
This convention... |
null |
In Algorithm Design and Applications by Michael T. Goodrich and Roberto Tamassia Chapter 12.3 there is a presentation of a problem called the Telescope Scheduling problem.
Given n requests each with benefit, start time and end time, find the best combination of non conflicting requests that maximises the total benef... |
Telescope Scheduling Predecessors |
|algorithms|dynamic-programming| |
null |
[SMT][1] (satisfiablity-modulo-theories) solvers can provide an (almost-) push-button solution for at least a subset of such problems, especially for those that use machine-arithmetic, IEEE-floats, etc., where efficient decision procedures do exist. There's also good support for arrays and data-types, along with reason... |
[SMT][1] (satisfiablity-modulo-theories) solvers can provide an (almost-) push-button solution for at least a subset of such problems, especially for those that use machine-arithmetic, IEEE-floats, etc., where efficient decision procedures do exist. There's also good support for arrays and data-types, along with reason... |
[SMT][1] (satisfiablity-modulo-theories) solvers can provide an (almost-) push-button solution for at least a subset of such problems, especially for those that use machine-arithmetic, IEEE-floats, etc., where efficient decision procedures do exist. There's also good support for arrays and data-types, along with reason... |
[SMT][1] (satisfiablity-modulo-theories) solvers can provide an (almost-) push-button solution for at least a subset of such problems, especially for those that use machine-arithmetic, IEEE-floats, etc., where efficient decision procedures do exist. There's also good support for arrays and data-types, along with reason... |
> The problem is that I can't feed the code of f into h in main().
This problem is solved by invoking h with the machine address of f.
**Translated to C for the x86utm operating system**
01 int f(ptr x) {
02 if (h(x, x))
03 for (;;);
04 return 1;
05 }
06
07 int main() ... |
> The problem is that I can't feed the code of f into h in main().
This problem is solved by invoking h with the machine address of f.
**Translated to C for the x86utm operating system**
01 typedef int (*ptr)();
02
03 int f(ptr x) {
04 if (h(x, x))
05 for (;;);
06 return 1;... |
> The problem is that I can't feed the code of f into h in main().
This problem is solved by invoking h with the machine address of f.
**Translated to C for the x86utm operating system**
01 typedef int (*ptr)();
02
03 int f(ptr x) {
04 if (h(x, x))
05 for (;;);
06 return 1;... |
> The problem is that I can't feed the code of f into h in main().
This problem is solved by invoking h with the machine address of f.
**Translated to C for the x86utm operating system**
00 typedef int (*ptr)();
01 int h(ptr x, ptr y)
02
03 int f(ptr x) {
04 if (h(x, x))
05 f... |
null |
On top of everyone else, don't forget that the Curry-Howard correspondence also gives you a way to prove theorems.
Say you want to prove that $B \wedge (A \vee (B \rightarrow A)) \rightarrow A$. Here's the proof:
-- The statement of the theorem...
proof :: (b, Either a (b -> a)) -> a
-- ...and the p... |
> The problem is that I can't feed the code of f into h in main().
This problem is solved by invoking h with the machine address of f.
**Translated to C for the x86utm operating system**
00 typedef int (*ptr)();
01 int h(ptr x, ptr y)
02
03 int f(ptr x) {
04 if (h(x, x))
05 f... |
Spaghetti sort can sort numbers in linear time.
Assume without loss of generality that the numbers to be sorted are all in the interval $(0,1)$. A whole spaghetti has length $1$.
1. For each number cut one spaghetti to the corresponding length. This clearly takes $O(n)$.
2. Grab all the spaghetti and hit the w... |
[SMT][1] (satisfiablity-modulo-theories) solvers can provide an (almost-) push-button solution for at least a subset of such problems, especially for those that use machine-arithmetic, IEEE-floats, etc., where efficient decision procedures do exist. There's also good support for arrays and data-types, along with reason... |
As far as I know for Non-Deterministic Turing Machine (NTM) there are 3 kind of brunches:
1) An input is accepted if there is at least one node in the tree that is an accept.
2) An input is rejected if all branches are rejected, which means that it is a finite tree.
3) An input is not-accepted if there are loop no... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.