Q5 Using Two Nested “For Loops” For The Implementation Of The 3 Sum Problem

Q5 Using Two Nested “For Loops” For The Implementation Of The 3 Sum Problem. Q5 Using two nested “for loops” for the implementation of the 3 Sum problem. The runtime of the algorithm was O(N 2 ). But the runtime for this problem can be further reduced using a hash-table approach (ignoring the inner functionality of Hash-Tables in the worst case). Using the concept of hash-tables , provide an algorithm that returns three distinct elements in an array A that sum to 0 (you can print the numbers iteratively). All elements in the array are integers with no duplicate values. algorithm should have a run time < O(N 2 ).

need explanation for the run time.

Input array A: {-6,-5,0,1,2,3,4,5,6}

Output:

-6,0,6

-6,1,5

-6,2,4

-5,0,5

-5,1,4

-5,2,3

Q5 Using Two Nested “For Loops” For The Implementation Of The 3 Sum Problem