Why so many C data structures and algorithms books suggest the use of a linked list as support for implementing a stack ? A dynamic array is faster and more cache friendly.
@sol_prog Back in the day when memory pressures were greater and on processors without memory caches, linked lists were more efficient for many operations—especially when implementing a stack. Even better: pooled allocation of linked list objects.
@sol_prog Maybe because cache misses weren’t relatively so severely expensive when the books were written? That’s my guess.
@sol_prog A lot of multithreading books use linked lists for stacks, sadge tbh.
@sol_prog All the books and classes I had growing up made linked lists look amazing and now I almost always use a simple array / pool. Unless you have wildly variable structure sizes (which raises more questions) it's almost always better to use one or more arrays.