Search a title or topic

Over 20 million podcasts, powered by 

Player FM logo
Artwork

Content provided by Andrea Angella - Senior Software Engineering Manager, former Microsoft C# MVP, Andrea Angella - Senior Software Engineering Manager, and Former Microsoft C# MVP. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Andrea Angella - Senior Software Engineering Manager, former Microsoft C# MVP, Andrea Angella - Senior Software Engineering Manager, and Former Microsoft C# MVP or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://podcastplayer.com/legal.
Player FM - Podcast App
Go offline with the Player FM app!

Learn to code a Min Heap from scratch in modern C# (for .NET developers)

28:39
 
Share
 

Manage episode 498118850 series 2560973
Content provided by Andrea Angella - Senior Software Engineering Manager, former Microsoft C# MVP, Andrea Angella - Senior Software Engineering Manager, and Former Microsoft C# MVP. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Andrea Angella - Senior Software Engineering Manager, former Microsoft C# MVP, Andrea Angella - Senior Software Engineering Manager, and Former Microsoft C# MVP or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://podcastplayer.com/legal.
I was a little bored recently and thought to myself, why not implement a Heap data structure in C# from scratch just to keep my mind sharp? 🙂I still remember the first time I came across this data structure at university — I was immediately fascinated. What a clever idea: representing a binary tree using an array and applying a simple invariant to build an in-place, stable sorting algorithm like HeapSort.Now, if you ask most engineers whether they could implement a heap from scratch, they'd probably say no — and that’s perfectly fine. But you don’t want to be just an average engineer, right?If you understand what a Heap is and how to use simple index math to navigate the tree up and down, you can figure out how to implement it — even if you don’t remember the details. Memorizing an algorithm is rarely helpful. Instead, focus on understanding the core concept. Once you do, you’ll find it surprisingly easy to reimplement it whenever needed.IMPORTANT: If you're solving a problem in .NET and need a heap, I strongly recommend using the built-in PriorityQueue class. It’s backed by a quaternary min-heap and optimized for performance. Still, it’s valuable to understand how it works under the hood — and you'll be surprised how few lines of modern C# it takes to implement your own.Happy C# coding!
  continue reading

52 episodes

Artwork
iconShare
 
Manage episode 498118850 series 2560973
Content provided by Andrea Angella - Senior Software Engineering Manager, former Microsoft C# MVP, Andrea Angella - Senior Software Engineering Manager, and Former Microsoft C# MVP. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Andrea Angella - Senior Software Engineering Manager, former Microsoft C# MVP, Andrea Angella - Senior Software Engineering Manager, and Former Microsoft C# MVP or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://podcastplayer.com/legal.
I was a little bored recently and thought to myself, why not implement a Heap data structure in C# from scratch just to keep my mind sharp? 🙂I still remember the first time I came across this data structure at university — I was immediately fascinated. What a clever idea: representing a binary tree using an array and applying a simple invariant to build an in-place, stable sorting algorithm like HeapSort.Now, if you ask most engineers whether they could implement a heap from scratch, they'd probably say no — and that’s perfectly fine. But you don’t want to be just an average engineer, right?If you understand what a Heap is and how to use simple index math to navigate the tree up and down, you can figure out how to implement it — even if you don’t remember the details. Memorizing an algorithm is rarely helpful. Instead, focus on understanding the core concept. Once you do, you’ll find it surprisingly easy to reimplement it whenever needed.IMPORTANT: If you're solving a problem in .NET and need a heap, I strongly recommend using the built-in PriorityQueue class. It’s backed by a quaternary min-heap and optimized for performance. Still, it’s valuable to understand how it works under the hood — and you'll be surprised how few lines of modern C# it takes to implement your own.Happy C# coding!
  continue reading

52 episodes

All episodes

×
 
Loading …

Welcome to Player FM!

Player FM is scanning the web for high-quality podcasts for you to enjoy right now. It's the best podcast app and works on Android, iPhone, and the web. Signup to sync subscriptions across devices.

 

Copyright 2025 | Privacy Policy | Terms of Service | | Copyright
Listen to this show while you explore
Play