edited by
779 views
0 votes
0 votes
you are given an array which contain both positive and negative integers in it and asked to design an algorithm to find maximum sum which doest contain twp consecutive numbers .what is the time complexiy of efficient algorithm ?

nlogn

n2

n

n2logn
edited by

1 Answer

0 votes
0 votes
I think in this question apply  2 pass bubble sort which give two largest number which is order of (n) and add two last elements which give constant
Answer:

Related questions

0 votes
0 votes
0 answers
1
Sajal Mallick asked Nov 27, 2023
171 views
As we have to select maximal set of “non overlapping” activities. So like job scheduling algo of greedy we can solve it. So according to that complexity must be O(n l...
0 votes
0 votes
1 answer
3
Ray Tomlinson asked Aug 9, 2023
425 views
How many times is the comparison $i >= n$ performed in the following program?int i = 200 n = 80; main() { while (i >= n) { i = i - 2 n = n + 1 } }