Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 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

Step: 1

1 Algorithm to find whether any three elements add up to 0 in a set S of n integer elem... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Algorithms

Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest

3rd edition

978-0262033848

More Books

Students also viewed these Programming questions

Question

If the person is a professor, what courses do they teach?

Answered: 1 week ago

Question

Suppose P(A)=.1 and P(B)=.5. 7. If P(A|B)=.1, what is P(AB)?

Answered: 1 week ago