LearnFrenzy
Sign in Take a free test

STL Algorithms and Iterators · STL Algorithms MCQ · Question 18

accumulate versus reduce Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 18 Back to Exercise

What is the key difference between std::accumulate and std::reduce?

  • A reduce only works on ints
  • B reduce may reorder and group operations (enabling parallelism), so the operation must be associative and commutative Correct
  • C accumulate is parallel
  • D There is none
Correct Answer: Option B

With string concatenation or floating-point sums the results may differ.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links