find sum of first i/2 smallest numbers in array at index i

Revision en5, by anucode, 2024-05-17 13:48:11

We have an array of integer and we want at evey odd index i we have to find sum of first i/2 smallest number from index 1 to index i

lets

At index 1 sum of 0 smallest number

At index 3 sum of first one smallest number

At index 5 sum of first two smallest number

At index 7 sum of first three smallest number

At index 9 sum of first four smallest number

and so on.

any solution/Idea in o(n) or o(nLogn) ?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English anucode 2024-05-17 13:48:11 5 Tiny change: 'y solution in o(n) o' -> 'y solution/Idea in o(n) o'
en4 English anucode 2024-05-17 13:39:00 16
en3 English anucode 2024-05-17 13:36:33 22 Tiny change: 'x i\nlets at index i is equal to\nAt index' -> 'x i\nlets \nAt index'
en2 English anucode 2024-05-17 13:34:21 5
en1 English anucode 2024-05-17 13:33:38 482 Initial revision (published)