Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
Linked Lists in C#: Nodes, Sentinels and Classic Problems
A linked list removes a node you hold in O(1) but pays for a separate object per element: 100,000 ints take 400 KB in a List and 4.8 MB in a LinkedList<int>, and walking 1 million scattered nodes is 259 times slower than a List. We write singly and doubly linked lists with sentinels, in-place reverse, Floyd's cycle detection, the middle node and a sorted merge, all with xUnit tests.
Arrays and Dynamic Arrays in C#: Contiguous Memory, Indexing and Writing Your Own List
A dynamic array is an array that moves to a new array twice its size when it fills up; 1,000,000 Adds copy only 1,048,572 elements in total, so the cost per element is constant. We write our own DynamicArray<T> with xUnit tests, explain why a removed slot must be cleared for the GC, and show with BenchmarkDotNet that walking a 4,000×4,000 grid column by column is 3 times slower than row by row.