Skip to content
Search lessons, topics, tests…
Esc

    ↑ ↓ moveEnter openEsc close
    LINQ: back to the track

    Guided course · LINQ

    Time and Space Complexity in LINQ

    Explain LINQ costs by counting work and tracing retained data.

    • Compare streaming, buffering, hashing, sorting and repeated enumeration.
    • Distinguish allocated bytes from peak retained memory and database work.
    • Examples and measurements run on .NET 10; each cost model states its assumptions.
    Intermediate8 modules · 24 lessons · 7 h 1 min · 36 practice tests · 25 coding problems · 2 free

    Module 1 · Foundations

    3 lessons · 45 min
    1. 01Big-O for .NET Developers: Time and Space in LINQFree, 2 practice tests16 min
    2. 02Deferred Execution and Multiple Enumeration: Paying for the Same Query TwiceFree, 2 practice tests15 min
    3. 03Query Syntax vs Method Syntax: What the C# Compiler Turns a LINQ Query Into (included with Full Access), 1 practice test14 min

    Module 2 · Streaming vs Buffering

    4 lessons · 1 h 4 min
    1. 04Streaming Operators: Where, Select and Take in O(1) Extra Space (included with Full Access), 1 practice test15 min
    2. 05OrderBy Under the Hood: O(n log n), an O(n) Buffer, Stability and Top-k (included with Full Access), 2 practice tests18 min
    3. 06Hidden Buffers: Reverse, ToList/ToArray Growth, Distinct and Set Operators (included with Full Access), 2 practice tests18 min
    4. 07Write Your Own LINQ Operator: yield, Early Argument Checks, Disposal and Buffering (included with Full Access)13 min

    Module 3 · Hashing Operators

    2 lessons · 35 min
    1. 08Hashing Operators: GroupBy, ToLookup, ToDictionary, CountBy and AggregateBy (included with Full Access), 2 practice tests18 min
    2. 09Nested Queries O(n·m) vs Join and HashSet O(n+m) (included with Full Access), 2 practice tests17 min

    Module 4 · Element Operators and Fast Paths

    2 lessons · 33 min
    1. 10Contains, Any and Count: Fast Paths on List, HashSet and IEnumerable (included with Full Access), 2 practice tests17 min
    2. 11First, Last, ElementAt and Single: When They Are O(1) and When O(n) (included with Full Access), 2 practice tests16 min

    Module 5 · Shape-Changing Operators

    4 lessons · 1 h 1 min
    1. 12SelectMany, Zip and Chunk: Flattening, Pairing and Batching Costs (included with Full Access), 2 practice tests15 min
    2. 13Skip, Take and Paging: O(1) Seeks, O(skip) Walks and Quadratic Paging (included with Full Access), 2 practice tests17 min
    3. 14Aggregate, Sum, Min and Max: Same O(n), Very Different Constants (included with Full Access), 2 practice tests15 min
    4. 15LINQ Edge Cases Interviewers Test: Empty Input, Nulls, Overflow, Duplicates and Ties (included with Full Access), 1 practice test14 min

    Module 6 · Allocations and Garbage Collection

    3 lessons · 53 min
    1. 16Where LINQ Allocates: Iterators, Delegates, Closures, Enumerators and Boxing (included with Full Access), 2 practice tests17 min
    2. 17GC Pressure from LINQ: Gen0/1/2, the LOH, and Measuring with BenchmarkDotNet and dotnet-counters (included with Full Access), 2 practice tests17 min
    3. 18Allocation-Free Alternatives: Loops, Span<T>, ArrayPool and Pre-Sizing (included with Full Access), 2 practice tests19 min

    Module 7 · IQueryable and EF Core

    4 lessons · 1 h 2 min
    1. 19IQueryable and EF Core: When the Cost Moves to SQL (N+1, Early ToList, Contains, Paging) (included with Full Access), 2 practice tests23 min
    2. 20Expression Trees in LINQ: Func vs Expression<Func> and What a Provider Sees (included with Full Access), 1 practice test15 min
    3. 21Dynamic LINQ Queries: Conditional Filters, OR Rules and Safe Sorting by Name (included with Full Access)13 min
    4. 22Async LINQ in .NET 10 and PLINQ: Streams, Cancellation and Parallel Queries (included with Full Access), 1 practice test11 min

    Module 8 · Practice and Assessment

    2 lessons · 1 h 8 min
    1. 23Practice Set: 12 "Find the Complexity and Fix It" Exercises (Solved and Measured) (included with Full Access), 1 practice test33 min
    2. 24Final Mock Interview: 25 Questions on LINQ Time and Space Complexity (included with Full Access)35 min

    Coding problems

    TechInterviewNotes Editorial Team ·