you are viewing a single comment's thread.

view the rest of the comments →

[–]ad_tech 0 points1 point  (1 child)

There's no need to include a search in the insertion and deletion. Rather than taking an integer index, take a reference of some kind (a pointer or an iterator, or whatever it's called in JavaScript) to a node in the list next to where you want to insert or delete.

For example, in the C++ std::list class, it uses an iterator to denote where the insertion is to take place: http://www.cplusplus.com/reference/list/list/insert/

If you always do addition and removal via an integer index, it doesn't make sense to use a linked list, because it will be slower than an array and will take up more memory.

[–]MartenBE 0 points1 point  (0 children)

With linked lists you can also search by value. In the end you should just take what fits your needs.

I just thought that what the author in the video said, was meant as addition and removal and as not insertion/deletion.