0

When should you use linked list in C++?

Getting them mixed up with arrays and such. What type of situation in the world would require you to use linked list?

5th Nov 2024, 6:17 AM
Tantina4337
5 Respuestas
+ 3
In a stenography translator that I wrote I used a linked list to construct a syllable database where syllables were related by links in order to parse and construct whole words. The database was self-optimizing as syllables were accessed and self-balancing as words were added, which was a matter of replacing links instead of rearranging the data. So in this case it was a matter of time efficiency in which relational links could be updated quicker than moving the data.
5th Nov 2024, 9:36 AM
Brian
Brian - avatar
+ 3
a LINK to a nice article with a LIST of some use cases .😁😁😁 https://www.naukri.com/code360/library/application-of-linked-list-data-structure
5th Nov 2024, 10:38 AM
Bob_Li
Bob_Li - avatar
+ 2
Usually when you want to track the previous node like for example a train station where station is the Linked list and the items there are the station and the train. You might want to track easily the previous and next station with linked list as they are "Linked"
5th Nov 2024, 6:44 AM
John Albert Flores
John Albert Flores - avatar
+ 1
@John Albert Flores Thanks. Do programmers actually use linked lists? Do they actually use it for tracking destinations of trains? Or is there a better approach?
5th Nov 2024, 9:22 AM
Tantina4337
+ 1
Tantina4337 I like your question in the comment. Do programmers actually use linked lists? Do they actually use it for tracking .....? Is there a better approach? Well, to answer that. We don't ! It's my 15yrs as a professional in c++ and vector will always come out as the best choice 99.999% of the time. The only time I remember using std::forward_list is for a spatial acceleration demonstration I wrote in 2019, then I don't have any choice cos I'm working with over 5 million entities and optimization is very important. Since rvalue reference now exists, it's even giving vector more power. I rarely see anyone use anything other than vector. Now going into the source code of tensorflow c++, deque is used many times as much as vector.
5th Nov 2024, 12:03 PM
RuntimeTerror
RuntimeTerror - avatar