Introduction
There is no C# class like Java PriorityQueue for minimum heap. I learned to write a minimum heap using SortedDictionary since I read the source code to study the problem solving of the algorithm called Merge k sorted lists recently.
I like to write a blog to document my experience.
Source code
Here is C# source code to write a minimum heap using SortedDictionary. Also the folder is here to access my practice for the algorithm 23 Merge K sorted lists.
Challenge
Julia, you spent 10 rounds of mock interviews from March 2017 to June 2018. You could not come out using SortedDictionary to write a simple minimum heap for K messed sorted array algorithm.
Give a few arguments to defend yourself:
I do not spend time to read SortedDictionary source code.
I do not know how SortedDictionary class is designed, why it is needed.
I do not try to memeorize all APIs from SortedDictionary.
I do not have chance to read the code using SortedDictionary to solve the problem.
I did search why C# does not provide PriorityQueue like Java, but I do not find alternatives with source code using SortedDictionary.
I got so many choices to continue to study and improve. I just move on other problems to solve.
Give a few advice how to break through the problem:
Please provide a possible three solutions you can approach to come out a written solution like using SortedDictionary.
Follow up
March 26, 2019
I reviewed the solution written for union find algorithm, and then I will write new version using SortedDictionary as well.
Here is the folder to contain my practice.
Here is the union find algorithm using SortedDictionary
Follow up
June 4 2020
I like to work on 215 Find kth largest element in the array using SortedDictionary. The idea is to write a solution using minimum heap.
No comments:
Post a Comment