In C++ STL, which algorithm is most suitable for rearranging elements in a range, so they are in reversed order? 

  • sort() 
  • reverse() 
  • swap() 
  • rotate()
The reverse() algorithm in C++ STL is explicitly designed to reverse the elements in a specified range. While other algorithms like sort(), swap(), and rotate() have different primary purposes, only reverse() guarantees the desired effect for this use-case.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *