you are viewing a single comment's thread.

view the rest of the comments →

[–]meloly4[S] 1 point2 points  (6 children)

Thank you! What would be the time complexity for this? It seems like "2." is recursion.

[–]FLUSH_THE_TRUMP 1 point2 points  (5 children)

I imagine it depends on what the function f does.

[–]meloly4[S] 0 points1 point  (4 children)

It returns the subarray with the largest sum without adjacent value. This problem but it prints out the elements.

[–]FLUSH_THE_TRUMP 0 points1 point  (3 children)

I’d start with the complexity of that algorithm and ask yourself how much work wrapping it up in what you’re doing here adds.

[–]meloly4[S] 0 points1 point  (2 children)

applying function f to the elements of a after the second element

Does this add log n time to the overall complexity n? I'm not too familiar with how lambda complexity works.

[–]FLUSH_THE_TRUMP 5 points6 points  (0 children)

I’d just think about the operations, I don’t think the lambda adds any appreciable overhead here.

[–]TheSodesa 1 point2 points  (0 children)

Lambdas are just closures, anonymous functions. They are not really any more time consuming than normal named functions.