C# Data structure talk: List, Stack, Queue, HashMap, HashSet and Tuple
May 27, 2020
It is important for me to train myself to get familar with C# data structure and also think better what to choose in design process. There are more than five solutions I like to share using C# data struture: List, Stack, Queue, Dictionary (HashMap), HashSet, Tuple.
Here are my highlights:
- First and most important, it is to learn and get familiar using List, and understand tree traversal, use one path as List variable to solve backtracking issue;
- Next it is important to learn how to solve the algorithm using recursive function without any data structure;
- Advanced topic is to try ideas using Tuple<TreeNode, int> and experience how efficient it is to design and remove ambiguity in design, follow Single Responsiblity Principle SRP.
- Try other options like Stack, HashSet if you have time to practice.
Data structure is the tool to get organized
Let us get started. First one is combination of Queue, Dictionary, HashSet
No 1 combinations: C# Data structure: Queue, Dictionary, HashSet
child-parent map, parent node, BFS (May 11, 2019)
child-parent map, parent node, BFS (May 11, 2019)
No 1 combinations: C# Data structure: Queue, Dictionary, HashSet
how to build a path from p or q to root (May 11, 2019)
how to build a path from p or q to root (May 11, 2019)
Next is data structure C# List
C# List is enough to solve the problem - topics: backtracking, space optimization
Space complexity analysis
learn elegent solution using back tracking and space efficiency, avoid timeout (May 23, 2019)
learn elegent solution using back tracking and space efficiency, avoid timeout (May 23, 2019)
Next is C# HashSet
No 3 combinations: C# Data structure: HashSet
Find the path H for node p, and find path for node q and also check hashset for path H, June 14, 2019 mock interview case study Clever idea!
Find the path H for node p, and find path for node q and also check hashset for path H, June 14, 2019 mock interview case study Clever idea!
June 25, 2019
find one path first and then look up path for second given node q
C# find path from given node p to root first and then find q and lowest common ancestor
C# find path from given node p to root first and then find q and lowest common ancestor
find one path first top down and then look up path for second given node q
C# Find top down path for a given node p and then find q's path and look up lowest common ancestor
C# Find top down path for a given node p and then find q's path and look up lowest common ancestor
Next is C# Stack
Stack is perfect to maintain the order in last in first out order.
No 4 combinations: C# Data structure: Stack
Using Stack data structure
Recursive function using Stack return Stack (June 10, 2019)
Recursive function using Stack return bool (June 10, 2019)
Using Stack data structure
Recursive function using Stack return Stack (June 10, 2019)
Recursive function using Stack return bool (June 10, 2019)
Next is C# Tuple
Tuple is so powerful and time-efficient, good at strong type definition to avoid run time errors. Give it a try!
No 4 combinations: C# Data structure: Tuple
Return Tuple<TreeNode, int> or ArrayList? Always strong typing
C# Postorder traversal and count nodes found practice in 2020 Learn from ex-facebook engineer, super performance, April 30, 2020
Return Tuple<TreeNode, int> or ArrayList? Always strong typing
C# Postorder traversal and count nodes found practice in 2020 Learn from ex-facebook engineer, super performance, April 30, 2020
May 25, 2020
C# Tuple<TreeNode, int> design talk and second practice on May 25 2020
C# Tuple<TreeNode, int> design talk and quick practice in May 25 2020
C# Tuple<TreeNode, int> design talk and second practice on May 25 2020
C# Tuple<TreeNode, int> design talk and quick practice in May 25 2020
It is time for me to learn to review my own code. Track my progress and I was so surprised to learn that I need to practice backtracking in 2019, 53 year old.
Extra topic: backtracking, List
Follow up with review
May 26, 2020
C# Find path from root to p practice on May 26, 2020
C# Critic my own code written on May 7, 2019 Write review for my own code after 12 months
Follow up with review
May 26, 2020
C# Find path from root to p practice on May 26, 2020
C# Critic my own code written on May 7, 2019 Write review for my own code after 12 months
No comments:
Post a Comment