Gate2020 cs Q13

0. What is the worst case time complexity of inserting n elements into an empty linked list, if the linked list needs to be maintained in sorted order?

  • Option : C
  • Explanation :
    Inserting an element at the beginning of the linked list takes O(1) time. But, If it needs to be sorted, then in the worst case, it takes (log n) time using merge sort. To insert such n elements and make sure it is in sorted order, the worst case time complexity would be O(n log n).
Cancel reply

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


Cancel reply

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