This is My problem:
Given a number x and 4 sequences A, B, C and D, each of n numbers, decide whether there exists some numbers a from A, b from B, c from C and d from D such that x = a+b+c+d. Operations alowed are comparisons, additions and swaps. Design an efficient algorithm to solve this problem with a worst case running time less than n^4.
I have no idea where to start and would appreciate some help!
You could do the following:
Investigate AB[abi]+CD[cdi], check conditions and increment/decrement indices
Every time we do step 4 an index is either incremented or decremented (or the algorithm stops) so we are doing step 4 at most 2*n^2 times (the number of elements across both arrays) - O(n^2)
So all in all we have O(n^2 log(n))