Question: In Python, create the program for a b c Pair-Sum-Problem: The problem involves generating a random sequence of N integers ranging from -1,000,000,000 to 1,000,000,000,
In Python, create the program for a b c
Pair-Sum-Problem: The problem involves generating a random sequence of N integers ranging from -1,000,000,000 to 1,000,000,000, after taking the input size (N) from the user. Once the random array of N integers is generated, the program prompts the user for an input K and determines whether there exist two numbers in the array whose sum equals K. For example, if the random sequence is (8. 4. 1, 6, 33 and K is 10, then the program outputs 'yes' since 4 + 6 = K. If N is less than 20, the program must prompt the user for both N integers and K. Do the following: a) Provide a solution to the problem with a time complexity of O(N). Explain your approach and analyze the time complexity of your solution. b) Provide a solution to the problem with a time complexity of O(N log N). A hint is given to sort the array before finding the required numbers. Describe your approach and analyze the time complexity of your solution. c) Provide a solution to the problem with a time complexity of O(N) using a hash table. Explain your approach and analyze the time complexity of your solution.
Step by Step Solution
3.42 Rating (152 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
