Question: Help me with this algorithm question Suppose you are given an integer c and an array, A, indexed from 1 to n , of n

Help me with this algorithm question

Suppose you are given an integer c and an array, A, indexed from 1 to n, of n integers in the range from 0 to 3n (possibly with duplicates).

1. Write an efficient algorithm in a pseudo code for determining if there are two integers, A[i] and A[j], in A whose difference is c, i.e. c = |A[j] - A[i]|, for 1 i < j n.

2. What is the running time of your algorithm in Big-Oh notation? Justify your answer.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!