Question: 1. [10pnts] Given a set S of n integer elements write and algorithm to find whether any three elements (not necessarily distinct) add up

1. [10pnts] Given a set S of n integer elements write and

1. [10pnts] Given a set S of n integer elements write and algorithm to find whether any three elements (not necessarily distinct) add up to 0. A pseudo code would suffice. What is time complexity of your algorithm? (e.g.: for n=6 and S-={-2,9,-2,12,4,-15,-13}, the numbers -2,-2,4 add up to 0. Note that you cannot use a single element multiple times. Thus, -2,-2,-2,-2,-2,-2,12 is NOT correct). Answer: 2. [10 pnts] You are given two sorted list of N integers in ascending order e.g., A= {-1, 3, 4, 7,8, 12), and B={5, 9, 10, 13, 14, 15}. Give an algorithm to merge these two lists to a single list in ascending order. A pseudo code would suffice. What is time complexity of your algorithm?

Step by Step Solution

3.37 Rating (153 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

1 Algorithm to find whether any three elements add up to 0 in a set S of n integer elem... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!