I was breaking a sweat over this question. I was asked to answer (this is technically homework). I looked at the hash table, but I'm kind of fixated on the exact specifics of how I will do this work.
Here's the question:
For k sets of integers A 1 , A 2 , .., A k of total size O (n), you must determine if a 1 ε A 1 , a 2 ε A 2 , .., a k ε A k , so a 1 + a 2 + .. + a k & minus; 1 = a <sub> xub>. Your algorithm should work at T k (n) time, where T k (n) = O (n k / 2 x log n) for even k and O (n (k + 1) / 2 ) for odd k .
Can someone give me a general direction so that I can come closer to solving it?
hashtable algorithm backtracking subset-sum
Arnon
source share