edited by
1,608 views
0 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

1 Answer

0 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:
Position:
Show:

Related questions

0 0 votes
1 answers 1 answer
2.3k
2.3k views
Bikram asked Nov 26, 2016
2,331 views
Three algorithms do the same task. Algorithm One is $O(N)$ and Algorithm Two is $O(\log N)$ and Algorithm Three is $O(N1/2)$. Which algorithm should execute the fastest f...
0 0 votes
0 0 answers
144
144 views
Ay_Kay_Ay asked Dec 2, 2024
144 views
Consider the pseudocode below, where $\mathrm{n} \% 6$ denotes the remainder when n is divided by 6 . The notation $n / / 2$ stands for integer division, i.e., $15 / / 2=...
1 1 vote
2 2 answers
365
365 views
Shubham Sharma 2 asked Jun 12, 2025
365 views
Given an array $A=\left(a_{0}, a_{1}, \ldots, a_{n-1}\right)$ of integers, your task is to determine the maximum possible sum\[\operatorname{maxsum}(A)=\max _{0 \leq s \l...
0 0 votes
1 1 answer
526
526 views
Sajal Mallick asked Nov 27, 2023
526 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 logn)...