typedef unsigned int UInt;
typedef bool (*Func)(UInt);
// [Ret] true, if ∃c, 0<=c<=n, f(c)==1 and f is a P-time function.
// false, otherwise.
//
bool sat(Func f, UInt n) {
for(Uint c=0; c<=n; ++c) {
if(f(c)) return true;
}
return false;
}
Q: If it is NPC, what is the proof? If it it not, what is the complexity
classification of sat(..)?
On Mon, 2024-05-13 at 07:00 +0200, immibis wrote:
On 11/05/24 08:00, wij wrote:
typedef unsigned int UInt;
typedef bool (*Func)(UInt);
// [Ret] true, if ∃c, 0<=c<=n, f(c)==1 and f is a P-time function. >>> // false, otherwise.
//
bool sat(Func f, UInt n) {
for(Uint c=0; c<=n; ++c) {
if(f(c)) return true;
}
return false;
}
Q: If it is NPC, what is the proof? If it it not, what is the complexity
classification of sat(..)?
If UInt is a variable length integer, the amount of time that 'sat'
takes to run is usually proportional to 2 to the power of the size of
its input.
Sorry, there is ambiguity. The problem should be:
typedef unsigned int UInt; // arbitrary precision
typedef bool (*Func)(UInt);
[Problem] Given a P-time function Func f and a UInt variable n, compute whether
or not there exists a value c such that 0<=c<=n, f(c)==1.
Q: Is [Problem] a NP(or NPC) problem? If not, what the classification is it?
On 13/05/24 12:33, wij wrote:
On Mon, 2024-05-13 at 07:00 +0200, immibis wrote:
On 11/05/24 08:00, wij wrote:
typedef unsigned int UInt;
typedef bool (*Func)(UInt);
// [Ret] true, if ∃c, 0<=c<=n, f(c)==1 and f is a P-time function. >>>> // false, otherwise.
//
bool sat(Func f, UInt n) {
for(Uint c=0; c<=n; ++c) {
if(f(c)) return true;
}
return false;
}
Q: If it is NPC, what is the proof? If it it not, what is the
complexity
classification of sat(..)?
If UInt is a variable length integer, the amount of time that 'sat'
takes to run is usually proportional to 2 to the power of the size of
its input.
Sorry, there is ambiguity. The problem should be:
typedef unsigned int UInt; // arbitrary precision
typedef bool (*Func)(UInt);
[Problem] Given a P-time function Func f and a UInt variable n,
compute whether
or not there exists a value c such that 0<=c<=n, f(c)==1.
Q: Is [Problem] a NP(or NPC) problem? If not, what the
classification is it?
Depending on f, it could be NP with respect to the size of the input. Sometimes it won't be (e.g. when f always returns true or f(0) always
returns true).
On Thu, 2024-05-16 at 00:23 -0600, Jeff Barnett wrote:
On 5/11/2024 12:00 AM, wij wrote:
typedef unsigned int UInt;
typedef bool (*Func)(UInt);
// [Ret] true, if ∃c, 0<=c<=n, f(c)==1 and f is a P-time function.
// false, otherwise.
//
bool sat(Func f, UInt n) {
for(Uint c=0; c<=n; ++c) {
if(f(c)) return true;
}
return false;
}
Q: If it is NPC, what is the proof? If it it not, what is the complexity
classification of sat(..)?
In normal CS Speak:
Problems have complexity: essentially defined as the worst case behavior
as problem size grows. One then minimizes this over all algorithms that
"solve" the problem as specified.
An Algorithm has runtime: essentially what is the worst case runtime for
each problem size.
You seem to be asking for complexity of an algorithm. It's easy to see
that the above algorithm is exponential (or worse depending on f). One
can assume that f, in worst case, has runtime that is a polynomial in
the length of n. However, these observations say absolutely nothing
about the complexity of the SAT problem.
--
Jeff Barnett
You said "...the above algorithm is exponential". But, it is just an assertion.
The question Q asks for the complexity of the problem sat(..) tries to solve and its supporting proof.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 493 |
Nodes: | 16 (2 / 14) |
Uptime: | 172:25:36 |
Calls: | 9,704 |
Calls today: | 4 |
Files: | 13,736 |
Messages: | 6,178,515 |