Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

GATE | GATE CS 2020 | Question 26

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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 ?

(A)

Θ(n)

(B)

Θ(n log n)

(C)

Θ(n2)

(D)

Θ(1)


Answer: (C)

Explanation:

If we want to insert n elements into an empty linked list that needs to be maintained in sorted order, the worst-case time complexity would be O(n^2). This is because we would need to traverse the list for each element we want to insert, to find the correct position for the element in the sorted list.

 


Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Last Updated : 11 Aug, 2021
Like Article
Save Article
Similar Reads