Mert Özen Further With Every Line

Blog

Mert Özen's blog posts on software development, backend, frontend, and DevOps.

Series
79 posts found
Backtracking: Pruning the Search Tree with Permutations, Subsets and Sudoku
Computer Science Fundamentals PART 19

Backtracking: Pruning the Search Tree with Permutations, Subsets and Sudoku

Backtracking tries every option systematically with choose, explore and unchoose steps; its real power is pruning branches that cannot reach a solution early: 2,057 nodes instead of 19 million for 8-Queens. In C# we write permutation, subset and combination generators with yield return, N-Queens, a Sudoku solver that starts from the most constrained cell, and a rule-based product configurator.

8 Nov 2026 13 min 28
Union-Find and Minimum Spanning Trees: Building Networks with Kruskal
Computer Science Fundamentals PART 18

Union-Find and Minimum Spanning Trees: Building Networks with Kruskal

With path compression and union by rank, Union-Find answers "are these two elements in the same group?" in practically constant time; the naive version is 4,300 times slower on a long chain. We write a DisjointSet in C#, merge duplicate customer accounts through shared e-mails and phones, build the cheapest fiber network between offices with Kruskal, and confirm the result with Prim.

8 Nov 2026 12 min 35
Shortest Paths: Dijkstra, PriorityQueue and a Brief Look at A*
Computer Science Fundamentals PART 17

Shortest Paths: Dijkstra, PriorityQueue and a Brief Look at A*

Dijkstra finds the cheapest path in a graph with non-negative weights: with lazy deletion, since PriorityQueue has no decrease-key, in O((V + E) log V). We trace Dijkstra step by step on an intercity shipping network, reconstruct the path, show the wrong result with a negative weight and Bellman-Ford, and measure A* finding the same path on a 200 × 200 warehouse grid with 1,845 cells instead of 33,600.

8 Nov 2026 11 min 40
Topological Sort and Cycle Detection: Dependency Order and Kahn's Algorithm
Computer Science Fundamentals PART 16

Topological Sort and Cycle Detection: Dependency Order and Kahn's Algorithm

Topological sort orders the vertices of a DAG so that every dependency comes before its dependents, in O(V + E); Kahn's algorithm uses in-degrees and a queue, DFS uses three colors. We write both in C#, produce seed data and build orders, report the cycle path, and show with real output that EF Core uses the same algorithm in SaveChanges and how the DI container reports a circular dependency.

8 Nov 2026 10 min 28
Graph Basics: Adjacency Lists, BFS and DFS Traversal
Computer Science Fundamentals PART 15

Graph Basics: Adjacency Lists, BFS and DFS Traversal

Sparse graphs are kept as adjacency lists and BFS finds the fewest steps in O(V + E); on a 5,000-vertex graph BFS over an adjacency matrix is 46 times slower. We write a generic Graph, BFS distances and paths, recursive and iterative DFS, connected components and a grid flood fill in C#, and show with real output that marking visited on dequeue makes 2 million enqueues instead of 2,000.

8 Nov 2026 12 min 35
Tries: Autocomplete, Prefix Search and Memory Cost in C#
Computer Science Fundamentals PART 14

Tries: Autocomplete, Prefix Search and Memory Cost in C#

A trie stores keys character by character and finds a prefix in O(m) steps, but its memory cost is high: for 234,456 words a sorted array takes 11.7 MB, a trie 148.9 MB. We write a trie with top-N suggestions in C#, solve the Turkish İ/ı case folding trap, build a minimal API and an Angular search box, and compare a sorted array, PostgreSQL LIKE and the trie with measurements.

8 Nov 2026 14 min 35
Heaps and Priority Queues: Binary Heap, Heapify, Heap Sort and Top-K in C#
Computer Science Fundamentals PART 13

Heaps and Priority Queues: Binary Heap, Heapify, Heap Sort and Top-K in C#

A heap is an array-backed tree that always keeps the smallest element on top; insert and remove-min are O(log n) and bottom-up build-heap is O(n). We write a BinaryHeap and heap sort in C#, show with real output that .NET's 4-ary PriorityQueue is not FIFO for equal priorities, and finish with top-K, k-way merge and running median examples plus a BenchmarkDotNet measurement.

8 Nov 2026 14 min 28
Balanced Trees: AVL, Red-Black and the B-Tree Behind Database Indexes
Computer Science Fundamentals PART 12

Balanced Trees: AVL, Red-Black and the B-Tree Behind Database Indexes

A balanced tree keeps its height at O(log n) whatever the insert order: with 10,000 sorted ids a plain BST is 10,000 levels tall, an AVL tree 14. We write AVL insert and rotations in C#, look at SortedSet's red-black tree through reflection, and inspect the levels and leaf chain of a real B+tree index in PostgreSQL with pageinspect.

8 Nov 2026 15 min 26
Trees and Binary Search Trees: Insert, Delete and Traversal in C#
Computer Science Fundamentals PART 11

Trees and Binary Search Trees: Insert, Delete and Traversal in C#

Search and insert in a binary search tree cost as much as the tree's height; inserting the same 10,000 IDs in sorted order turns the tree into a chain and 1,000 lookups become 221 times slower than in a randomly built tree. We write insert, find, the three cases of delete, recursive and iterative traversals, correct BST validation, and build a tree in O(n) from a flat category table with a Dictionary and serve it as JSON from an ASP.NET Core minimal API, with tests.

8 Nov 2026 15 min 34
Binary Search in Depth: Lower Bound, Off-by-One and Binary Search on the Answer
Computer Science Fundamentals PART 10

Binary Search in Depth: Lower Bound, Off-by-One and Binary Search on the Answer

The way to write binary search correctly is against an invariant, such as the half-open range [lo, hi); it makes at most 20 comparisons on 1 million elements, but a single boundary bug such as lo = mid sends it into an infinite loop. We write lower and upper bound, look at Array.BinarySearch's ~index return value, use binary search on the answer to find the minimum truck capacity and search a time range in a log, all with xUnit tests.

8 Nov 2026 12 min 25
Quick Sort, Introsort and Counting/Radix Sort: How .NET's Array.Sort Sorts
Computer Science Fundamentals PART 09

Quick Sort, Introsort and Counting/Radix Sort: How .NET's Array.Sort Sorts

Array.Sort uses introsort: quick sort, heapsort once the depth passes 2·log n, insertion sort for 16 elements or fewer; that is why a textbook quick sort with a last-element pivot becomes 749 times slower on 10,000 sorted elements while Array.Sort is unaffected. We cover Lomuto and Hoare partition, median-of-three, the Ω(n log n) lower bound, counting and radix sort that beat Array.Sort 11–12 times, and the a - b comparer trap, with tests.

8 Nov 2026 14 min 41
Sorting Algorithms 1: Insertion Sort, Merge Sort and Stability
Computer Science Fundamentals PART 08

Sorting Algorithms 1: Insertion Sort, Merge Sort and Stability

Array.Sort is not stable: sorting 200 date-ordered orders by customer scrambles each customer's dates, while merge sort and LINQ OrderBy keep them. We cover insertion sort (6 times faster than Array.Sort on 10,000 nearly sorted elements), top-down and bottom-up merge sort, the idea of external merge sort and stability, with xUnit tests and BenchmarkDotNet measurements.

8 Nov 2026 13 min 30
Blog Map