Sunday, August 22, 2010

What would be the O-notation for adding a word into an alphabetically sorted linked list?

what would be the O-notation for adding a word into an alphabetically sorted linked list?

What would be the O-notation for adding a word into an alphabetically sorted linked list?
I would say that it would be O(n) unless the list was also a binary tree which would be more efficient. The insertion even if the list is sorted would possibly have to look at every element in order to determine the insertion position.


No comments:

Post a Comment