Posts

Linking it Together

Image
There comes a point where every aspiring programmer must take their data structures class. That time is upon me, so I decided to give myself a head start. Today, I’ll be discussing what a Linked List is, including inline implementations for convenience.   As the name would suggest, Linked Lists are structures comprised of a sequence of nodes that hold some set of data. It’s a simple and elegant model that can be used as the basis for implementations of stacks, queues, and hashmaps.   But the question becomes, why use a Linked List instead of something like an array?   Firstly, arrays contain a fixed size or length, which detail how much data it will hold. Upon initialization, memory is allocated in regards to this specific size. However, Linked Lists are a dynamic data structure, allowing it to scale its size and allocate memory during runtime.  Due to arrays’ fixed size, it becomes difficult to add data if the array is already full. To do so would require initializing a comp