in Algorithms
969 views
0 votes
0 votes
Suppose, we have an array of n elements. find the time complexity to search two elements x, y such that:-

a) x+y < 100

b) x+y > 1000

Also, state the algorithm/approach for the same.
in Algorithms
969 views

4 Comments

Yes @Prateek right..
0
0
so, for the 1st part also we can apply 2 passes bubble sort(descending order code) & last 2 min. can be checked in

(n-1)+(n-2) comparisons. so, O(n). right??
0
0
Yeah right
0
0

Please log in or register to answer this question.

Related questions