1 votes 1 votes Consider the array of size n. the first (n – 1) elements are already sorted. What is the worst case time complexity to insert a nth element in an array after insertion the array should be in sorted order O(1) O(n) O(n log n) O(n2) Algorithms algorithms sorting time-complexity + – Akriti sood asked Dec 27, 2016 Akriti sood 2.0k views answer comment Share Follow See 1 comment See all 1 1 comment reply Akriti sood commented Dec 27, 2016 reply Follow Share i think this is same as last iteration of insertion sort to insert nth element into already sorted array of size (n-1),we have to compare maximum with (n-1) elements and shift (n-1) in worst case..so T(n) should be O(n) am i correct?? 2 votes 2 votes Please log in or register to add a comment.
Best answer 4 votes 4 votes it's take O(n) because in worst case , we need to shift (n-1) elements RAJESHWAR YADAV answered Dec 27, 2016 • selected Dec 27, 2016 by Akriti sood RAJESHWAR YADAV comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes It will be taking O(n) time Shivam14chd answered Mar 4, 2018 Shivam14chd comment Share Follow See all 0 reply Please log in or register to add a comment.