Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
Deriving Time Complexity from Code: Loops, log n and Recursion
To read complexity from code, add sequential blocks, multiply nested loops, call a loop that halves every step log n, and write a recurrence for recursion. With real counts: triangular loops, naive Fibonacci, merge sort, the master theorem, LINQ's hidden loops and an order-matching benchmark going from O(n·m) to O(n+m).
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.
Recursion in C#: Base Case, Call Stack, StackOverflowException and Converting to Iteration
In .NET a StackOverflowException cannot be caught and kills the whole process; on an 8 MB main thread an empty method called itself about 130,650 times and the catch block never ran. We cover the anatomy of recursion, call stack frames, converting recursive code to iteration with an explicit Stack<T>, and depth defences such as JSON MaxDepth (64) and EnsureSufficientExecutionStack, with xUnit tests and real output.