I thought of this simple algorithm to solve the 6SUM problem using O and n space (n ^ 3): Create all sets of triples and put them in a hash table where the key is the sum of triples. Then we sort through the keys of the hash table: for each key k1 see, Is there another key k2, so k2 = S-k1
What is a more efficient algorithm? This is not a homework problem.
Omega (n ^ 6), O (n ^ 3) . -. O (n ^ 3 logn), .
, P, 6 , .. .
3-SUM, , r-sum , o (n ^ [r/2]) (: smallOH [x] = >= x, [ 5/2] = 3) .
3-SUM , , .
, , O (n ^ 3) (.. o (n ^ 3)) .