-4

I have two tables:
T1(A,B) where
create table T1( A char(2) NOT NULL primary key check(T1.A not in T2.B), B char(2) unique );

T2(C,B) where
create table T2( C number(2) primary key, B char(2) unique references T1 check(T1.B not in T1.A) );

Here, T2.B references T1.A.

My question is that how can I put a check constraint to T1.A and T1.B such that values allowed by T1.A are different from those allowed by T2.B?

denizen
  • 458
  • 1
  • 5
  • 15
  • We need exponential time because no-one's been able to come up with a faster algorithm (if they do or prove it's impossible, they would prove / disprove [P = NP](http://en.wikipedia.org/wiki/P_versus_NP_problem)) (unless your question is why backtracking takes exponential time, which you should at least try to prove yourself before asking us). And the benefit and weight of items are given, so I'm not really sure what this is about - "what might be the benefit and weight of each item when there are N items". – Bernhard Barker Apr 22 '14 at 04:53

1 Answers1

0

The knapsack problem in worst case needs to verify all the subsets of the given knapsack to determine the best combination to put in knapsack hence its worst case performance using backtracking which essentially evaluates all valid combinations is O(2^n) which are no of subsets of given set of n items. Hence it has exponential time complexity.

Vikram Bhat
  • 6,106
  • 3
  • 20
  • 19