instruction
stringlengths
0
29.8k
⌀
<p>Let the sizes of the sets be $|S_a|=s_a$ and $|S_b|=s_b$. Then the sizes of their power-sets are $|P_a|=2^{s_a}$ and $|P_b|=2^{s_b}$. Thus the inner body of your double loop (a union operation, an append operation) gets executed $2^{s_a} * 2^{s_b}$ times. Suppose the operations in the inner body can be performed in ...
<p>Let the sizes of the sets be $|S_a|=s_a$ and $|S_b|=s_b$. Then the sizes of their power-sets are $|P_a|=2^{s_a}$ and $|P_b|=2^{s_b}$. Thus the inner body of your double loop (a union operation, an append operation) gets executed $2^{s_a} * 2^{s_b}$ times. Suppose the operations in the inner body can be performed in ...
Consider the following algorithm that merges two power-sets. Two sets $P_a = \mathcal{P}(S_a)$ and $P_b = \mathcal{P}(S_b)$ are given as input to the algorithm. We might assume the sets are implemented as [Python lists/sets](http://wiki.python.org/moin/TimeComplexity). $F = \emptyset$ $\forall M \in P_a$ $...
What is the complexity of this subset merge algorithm?
Given a set $\mathbf{S}$ of sets, I’d like to find a set $M$ such that every set $S$ in $\mathbf{S}$ contains at least one element of $M$. I’d also like $M$ to contain as few elements as possible while still meeting this criterion, although there may exist more than one $M$ with As a concrete example, suppose that ...
Given a set of sets, find the smallest set(s) containing at least one element from each set
|algorithms|
Given a set $\mathbf{S}$ of sets, I’d like to find a set $M$ such that every set $S$ in $\mathbf{S}$ contains at least one element of $M$. I’d also like $M$ to contain as few elements as possible while still meeting this criterion, although there may exist more than one smallest $M$ with this property (the solution is ...
For some graphs, DFS and BFS search algorithms process nodes in the exact same order provided that they both start at the same node. Two examples are graphs that are paths and graphs that are star-shaped (trees of depth $1$ with an arbitrary number of children). Is there some way for categorizing graphs that satisfy th...
1. Your answer is correct, $y$ is surely free. The model one is wrong. Maybe there was a typo and the answer was meant for $(\lambda y.xy)x$ 2. It depends on the precise definition of $BV$. Often only $FV$ is defined formally, because it's more important. (Bound variables can be [freely renamed](https://en.wikipedia...
I am reading Programming Language Pragmatics by Michael Scott. He says that on a first pass, a compiler will break a program into a series of tokens. He says that it will check for malformed tokens, like 123abc or $@foo (in C). What is a malformed token? A variable that does not meet the rules of variable-naming? A...
what is a malformed token?
|programming-languages|compilers|
I am reading Programming Language Pragmatics by Michael Scott. He says that on a first pass, a compiler will break a program into a series of tokens. He says that it will check for malformed tokens, like 123abc or $@foo (in C). What is a malformed token? A variable that does not meet the rules of variable-naming? A...
What is a malformed token?
The basic syntactic units in any programming language are tokens, which are, if you wish, the words in the programming language. The compiler parses these tokens to build sentences and so forth. A malformed token is a string of characters that is not a valid word for the programming language. It is not a variabl...
An idea that could help: if the intersection of all the sets in $\mathbf S$ in not empty, then you can pick any element $s$ in the intersection and set $M = \{s\}$. If the intersection is empty, find an element (color) $c$ whose occurrence in sets is maximum and replace all the sets in which it occurs by the singleton ...
The problem is the well-known NP-complete Problem [Hitting Set](http://en.wikipedia.org/wiki/Set_cover_problem#Hitting_set_formulation). It is closely related to [Set-Cover](http://en.wikipedia.org/wiki/Set_cover_problem). The NP-completeness proof can found in the classic [book of Garey and Johnson](http://dl.acm.org/...
The problem is the well-known NP-complete problem [Hitting Set](http://en.wikipedia.org/wiki/Set_cover_problem#Hitting_set_formulation). It is closely related to [Set-Cover](http://en.wikipedia.org/wiki/Set_cover_problem). The NP-completeness proof can found in the classic [book of Garey and Johnson](http://dl.acm.org/...
The basic syntactic units in any _textual_ programming language are tokens, which are, if you wish, the words in the programming language. The compiler parses these tokens to build sentences and so forth. A malformed token is a string of characters that is not a valid word for the programming language. It is not...
The problem is the well-known NP-complete problem [Hitting Set](http://en.wikipedia.org/wiki/Set_cover_problem#Hitting_set_formulation). It is closely related to [Set-Cover](http://en.wikipedia.org/wiki/Set_cover_problem). The NP-completeness proof can found in the classic [book of Garey and Johnson](http://dl.acm.org/...
null
|logic|lambda-calculus|
|algorithms|graph-theory|graphs|combinatorics|search-algorithms|
|complexity-theory|logic|satisfiability|
I was solving this equation:- $$key=(\sum_{K=0}^n\frac{1}{a^K})\mod m$$ ###Given $$ 1,000,000,000 < a, n, m \; < 5,000,000,000 $$ $$ a, m \; are \;coprime $$ I solved it bruteforcely but it won't work in the given constrains so I need a faster algorithm or is there is something I can notice to make the form...
Solving $key=(\sum_{K=0}^n\frac{1}{a^K})\mod m$ with High limits
|time-complexity|mathematical-analysis|discrete-mathematics|number-theory|
null
Solve a linear homogeneous recurrence (http://en.wikipedia.org/wiki/Recurrence_relation) to obtain the identity $$\sum_{K=0}^n\frac1{a^K}=\begin{cases}\frac{1-1/a^{n+1}}{1-1/a}&\text{if }a\neq1\pmod m\\n+1&\text{if }a=1\pmod m\end{cases}$$ and use efficient algorithms for [multiplicative inversion](http://en.wikipedia....
<p>It is very hard to define a human mind with a such mathematical rigor as it is possible to define a Turing machine. We still do not have a working model of a mouse brain however we have the hardware capable of simulating it. A mouse has around 4 million neurons in a cerebral cortex. A human being has 80-120 billion ...
Let A be reducible to B, i.e., $A \leq B$. Hence, the turing machine accepting $A$ has access to an oracle for $B$. Let the turing machine accepting $A$ be $M_{A}$ and the oracle for $B$ be $O_{B}$. The types of reductions: - Turing Reduction: $M_{A}$ can make multiple queries to $O_{B}$. - Karp Reduction: Also c...
types of reductions and associated definitions of Hardness
|complexity-theory|reductions|complexity-classes|
|algorithms|discrete-mathematics|number-theory|
I was solving this equation: $$\text{key}=\left(\sum_{K=0}^n\frac{1}{a^K}\right)\bmod{m}.$$ ###Given $$ 1,000,000,000 < a, n, m \; < 5,000,000,000, $$ $$ a, m \text{ are coprime}. $$ I solved it by brute force, but it won't work in the given constrains so I need a faster algorithm or is there is something I...
Solving $\text{key}=(\sum_{K=0}^n\frac{1}{a^K})\bmod m$ with High limits
Let A be reducible to B, i.e., $A \leq B$. Hence, the turing machine accepting $A$ has access to an oracle for $B$. Let the turing machine accepting $A$ be $M_{A}$ and the oracle for $B$ be $O_{B}$. The types of reductions: - Turing Reduction: $M_{A}$ can make multiple queries to $O_{B}$. - Karp Reduction: Also c...
|complexity-theory|np-complete|reductions|complexity-classes|
1. Your answer is correct, $y$ is surely free. The model one is wrong. Maybe there was a typo and the answer was meant for $(\lambda y.xy)x$ 2. It depends on the precise definition of $BV$. Often only $FV$ is defined formally, because it's more important. (Bound variables can be [freely renamed](https://en.wikipedia...
Solve [a linear homogeneous recurrence](http://en.wikipedia.org/wiki/Recurrence_relation) to obtain the identity $$\sum_{K=0}^n\frac1{a^K}=\begin{cases}\frac{1-1/a^{n+1}}{1-1/a}&\text{if }a\neq1\pmod m\\n+1&\text{if }a=1\pmod m\end{cases}$$ and use efficient algorithms for [multiplicative inversion](http://en.wikipedia...
Let A be reducible to B, i.e., $A \leq B$. Hence, the Turing machine accepting $A$ has access to an oracle for $B$. Let the Turing machine accepting $A$ be $M_{A}$ and the oracle for $B$ be $O_{B}$. The types of reductions: - Turing reduction: $M_{A}$ can make multiple queries to $O_{B}$. - Karp reduction: Also c...
Types of reductions and associated definitions of hardness
Is there any book or tutorial that teaches us how to apply the common algorithms (sorting, searching, etc.) on large data (i.e. data that cannot be fully loaded into main memory)? For example, almost all algorithm textbooks say that B and B+-trees can be used to store data on disk. However, actually how this can be don...
Applying algorithms on large data
|algorithms|
**Note:** There is a major flaw in my presentation of the algorithm which may impact its complexity results. I apologize for the same. Allow me some time to get it right. <hr></hr> Consider the following algorithm that merges two power-sets. Two sets $P_a = \mathcal{P}(S_a)$ and $P_b = \mathcal{P}(S_b)$ are given...
Consider this from a different perspective. * First-order logic is undecidable, that is, there is no decision procedure that determines whether arbitrary formulas are logically valid. (But the set of true first-order formulas is [semi-decidable](https://en.wikipedia.org/wiki/Semi-decidable), that is if a formula is ...
null
null
I think there is no way how give a definitive answer to this question, as nobody really knows the capabilities of human mind (and I doubt anyone ever will). But there is a view that gives one possible solution or explanation to this question: When we're searching an oracle to solve the halting problem (or decide ...
null
**Updated Algorithm:** There was a major flaw in my original presentation of the algorithm which could have impacted the results. I apologize for the same. The correction has been posted underneath. <hr></hr> The original algorithm posted had a major flaw in its working. I tried my best but could not get the desire...
Your definition of parsimonious reductions is incorrect. You are confusing it with polynomial-time one-one reductions which is a special case of Karp reductions. They don't preserve the number of "solutions". Please see [this answer](http://cs.stackexchange.com/a/2702/41) for more about reductions considering the numbe...
**Updated Algorithm:** There was a major flaw in my original presentation of the algorithm which could have impacted the results. I apologize for the same. The correction has been posted underneath. <hr></hr> The original algorithm posted had a major flaw in its working. I tried my best but could not get the desire...
Some people (including more than one moderators) complained to me for posting an answer based on a comment, and I am tired of defending me from them. I asked them to delete this answer.
Say you have m boolean inputs. You need to construct a boolean circuit (using AND, OR, NOT, XOR...) that evaluates to true if at least n (n < m) are true. Asymptotically how small can you make this circuit?
Circuit size for "at least n inputs are true"
|circuits|
From [S. Chaudhuri, J. Radhakrishnan. Deterministic Restrictions in Circuit Complexity][1]: **Theorem 6.1**: A circuit computing $T_k^n$ with $k \leq n^{1/3}$ has $\Omega(k^2(\ln n)/\ln k)$ gates Where the function $T_k^n$ has the value 1 iff at least $k$ of its inputs have the value 1. [1]: http://reposit...
"Given $f(x)$, what is $min(f(x))$?" --> "Given $f(x)$, and $k$, decide if there is an $x$ such that $f(x)< k$?"
An optimisation problem requires minimising some function f(x), where x is a vector of integers. what is the decision version of the problem?
Produce Decision version of the problem
|complexity-theory|optimization|reductions|
|complexity-theory|circuits|
An optimisation problem requires minimising some function $f(x)$, where $x$ is a vector of integers. What is the corresponding decision version of the problem?
Produce decision version of the problem
"Given $f(x)$, what is $\min(f(x))$?" becomes "Given $f(x)$, and $k$, decide if there is an $x$ such that $f(x)< k$?"
Say you have m boolean inputs. You need to construct a boolean circuit (using AND, OR, NOT, XOR...) that evaluates to true if at least n (n < m) are true. Asymptotically how small can you make this circuit? EDIT: Any reasonably tight upper bound would be appreciated. I keep on thinking of ways to recursively constr...
The $NP-Complete$ class of problems is defined w.r.t Karp Reductions, which are **polytime many-one reductions**. However, _they need not necessarily preserve the number of solutions_. A more restrictive type: **polytime one-one reductions** do indeed preserve the number of solutions. Suppose $f:\Sigma^{\ast}\to \ma...
Hardness of counting solutions to NP-Complete problems, assuming a type of reduction
|complexity-theory|reductions|complexity-classes|
In Tom Michell's Book "Machine Learning", Chap.1, a checkers game is used to illustrate how machine learning can be applied solve problems. An experience Propergation rule is described for iterative learning of hypothesis. Suppose a game has been played and watched by the program, the state of the endgame is labeled...
Why the Experience Propergation Rule for Checkers Works in Tom Mitchell's Book?
|machine-learning|
<p> <b>EDIT:</b> Since your new algorithm is slightly different, I present a new complexity analysis. I change the notation slightly of power-sets $P_a$ and $P_b$ to $P_1$ and $P_2$. Your algorithm generates a power-set $P = P(S_1 \cup S_2 \cup ... \cup S_n)$ where $P(S_i)=P_i$ given the power-sets $P_1, P_2, ..., P...
<p> <b>EDIT:</b> Since your new algorithm is slightly different, I present a new complexity analysis. I change the notation slightly of power-sets $P_a$ and $P_b$ to $P_1$ and $P_2$. Your algorithm generates a power-set $P = P(S_1 \cup S_2 \cup ... \cup S_n)$ where $P(S_i)=P_i$ given the power-sets $P_1, P_2, ..., P...
<p> <b>EDIT:</b> Since your new algorithm is slightly different, I present a new complexity analysis. I change the notation slightly of power-sets $P_a$ and $P_b$ to $P_1$ and $P_2$. Your algorithm generates a power-set $P = P(S_1 \cup S_2 \cup ... \cup S_n)$ where $P(S_i)=P_i$ given the power-sets $P_1, P_2, ..., P...
<p> <b>EDIT:</b> Since your new algorithm is slightly different, I present a new complexity analysis. I change the notation slightly of power-sets $P_a$ and $P_b$ to $P_1$ and $P_2$. Your algorithm generates a power-set $P = P(S_1 \cup S_2 \cup ... \cup S_n)$ where $P(S_i)=P_i$ given the power-sets $P_1, P_2, ..., P...
null
I'm now doing exam revision, and from some past year exam papers, I noticed some questions that ask to write a recursive method with signature like public void run(int n) that must have a time complexity of like : `O(n^2), O(n^3), O(n^7), O(n^2!), O(2^n), O(9^n)` Can anyone give some idea on how to solve thi...
How to write a recursive function that with certain time complexity
|time-complexity|recursion|
In Tom Mitchell's book ["Machine Learning"](http://www.amazon.com/Machine-Learning-Tom-M-Mitchell/dp/0070428077/ref=sr_1_1?ie=UTF8&qid=1345705928&sr=8-1&keywords=tom+mitchell+machine+learning), Chap.1, a checkers game is used to illustrate how machine learning can be applied solve problems. An experience propagation...
Why does the experience propagation rule for checkers work in Tom Mitchell's book?
null
The $\text{NP-Complete}$ class of problems is defined w.r.t Karp Reductions, which are **polytime many-one reductions**. However, _they need not necessarily preserve the number of solutions_. A more restrictive type: **polytime one-one reductions** do indeed preserve the number of solutions. Suppose $f:\Sigma^{\ast}...
I'm now doing exam revision, and from some past year exam papers, I noticed some questions that ask to write a recursive method with signature like public void run(int n) that must have a time complexity of like : $O(n^2), O(n^3), O(n^7), O(n^2!), O(2^n), O(9^n)$. Can anyone give some idea on how to solve th...
The idea is quite simple. Write your function `run` and analyze its time complexity $r(n)$. Is it then so that you can find *any* constant $c$ and input size $n_0$ such that from which $r(n_0) \leq cg(n_0)^2$? This idea comes from the [formal definition of Big Oh](http://en.wikipedia.org/wiki/Big_O_notation#Family_of_B...
null
|algorithms|time-complexity|recursion|
The idea is quite simple. Write your function `run` and analyze its time complexity $r(n)$. Is it then so that you can find *any* nonnegative constant $c$ and input size $n_0$ such that from which $r(n_0) \leq cg(n_0)^2$? This idea comes from the [formal definition of Big Oh](http://en.wikipedia.org/wiki/Big_O_notation...
From [S. Chaudhuri, J. Radhakrishnan. Deterministic Restrictions in Circuit Complexity][1]: **Theorem 6.1**: A circuit computing $T_k^n$ with $k \leq n^{1/3}$ has $\Omega(k^2(\ln n)/\ln k)$ gates Where $T_k^n$ is the boolean function that has the value 1 iff at least $k$ of its inputs have the value 1 (*threshold...
|algorithms|time-complexity|algorithm-analysis|check-my-algorithm|
When you are given a problem statement there will be an input.The given input has to be countable in some way. In order to get the answer or output you got to manipulate the input in some way are the other in programming. The question is ,how many operation are you going to do on your inputs ... it depends on problem r...
When you are given a problem statement there will be an input.The given input has to be countable in some way. In order to get the answer or output you got to manipulate the input in some way are the other in programming. The question is ,how many operation are you going to do on your inputs ... it depends on problem r...
Since nobody has bothered to answer this question, I will do it. As JeffE mentions in a comment, a [grid graph][1] is an example of a [bipartite graph][2]. If you take a bipartite graph, and remove some of the vertices, it will still be a bipartite graph. [Königs Theorem][3] states, that for bipartite graphs, the...