O(1) sum

Stefan Koch via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 11 18:36:04 PDT 2017


On Monday, 12 June 2017 at 01:02:58 UTC, helxi wrote:
> Is it possible to sum an array in O(1)?

No.
If you want to sum the elements you have to at-least look at all 
the elements.
So it'll always be O(N).
it's the best you can do.


More information about the Digitalmars-d-learn mailing list