0 votes 0 votes Is it really coping operation will take O(n). Does copy is done character by character. means simple code like (in c++) for(int i=0;i<n;i++) { s=s; } will take O($n^{2}$) Algorithms algorithms time-complexity test-series + – Overflow04 asked Oct 9, 2022 Overflow04 277 views answer comment Share Follow See 1 comment See all 1 1 comment reply Kabir5454 commented Oct 9, 2022 reply Follow Share append function c++ is take O(n) time complexity . You can think logically like you have a string S=”KHANSIR” now you want append ‘K’ at the end of the string. So to do that you have to traverse the entire string and have to add ‘K’ at the end which will take O(n) time. in C++ it is doing doing internally by operator overloading feature where ‘+’ is used as append function which is taking O(n) time . Now you are running this code n time for the for loop . so total time complexity is n*O(n)=O(n^2) . 1 votes 1 votes Please log in or register to add a comment.