Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to understand that the time complexity of Find(x) in linked list is Theta(1)?

Tags:

linked-list

I run into this when I reading the book but I don't understand. Don't we still have to compare through the list to find a specific element? Thanks.

like image 263
Alex Avatar asked Dec 04 '25 01:12

Alex


1 Answers

Yes you do. I'm not sure what attributes the linked list in your book includes, but it is possible (with indexing or another strategy) to have a search faster than O(n). Check out http://en.wikipedia.org/wiki/Linked_list#Speeding_up_search for more information on search optimization.

like image 150
Luigi Avatar answered Dec 06 '25 10:12

Luigi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!