I am self-studying C++ and the book \"Programming-Principles and Practices Using C++\" by Bjarne Stroustrup. One of the \"Try This\" asks this:
Implement square() wi
In term of the running time complexity,your implementation is clear and simply enough,its running time is T(n)=Θ(n) for input n elements.Of course you also can use Divide-and-Conquer method,assuming split n elements to n/2:n/2,and finally recursive compute it then sum up two parts,that running time will be like T(n)=2T(n/2)+Θ(n)=Θ(nlgn),we can find its running time complexity become worse than your implementation.