Graph and Trees: List of useful resource to help you understand and master Graph and Tree Data Structures
Published: 2020-11-22 17:19:04

The Graph and the Tree Data Structures are one of the most important concepts which are frequently asked in interviews of product-based companies. Questions based on graphs and trees can seem to be daunting at first and understanding and mastering graphs and trees requires lots of practice and patience.
![Alt Text](https://media.giphy.com/media/4JVTF9zR9BicshFAb7/giphy.gif)

But with the right resources and enough practice, graphs and trees can be tackled with ease in the interviews and you can gain confidence to deal with problems based on them in the interviews.

---

Here is a list of resources I compiled for myself that I am pretty sure can help you as well.

- Binary Trees and Binary Search Trees

    [Binary/ N-ary Trees Tutorials & Notes | Data Structures | HackerEarth](https://www.hackerearth.com/practice/data-structures/trees/binary-and-nary-trees/tutorial/)

    [Binary Search Tree Tutorials & Notes | Data Structures | HackerEarth](https://www.hackerearth.com/practice/data-structures/trees/binary-search-tree/tutorial/)

    HackerEarth is a brilliant platform to polish your skills of Data Structures and Algorithms. Here you can learn the basics from scratch as well as practice questions on easy, medium and hard difficulty.

    [Binary Tree - Interview Questions & Practice Problems - Techie Delight](https://www.techiedelight.com/binary-tree-interview-questions/)

    [Binary Search Tree (BST) - Interview Questions & Practice Problems](https://www.techiedelight.com/binary-search-tree-bst-interview-questions/)

    TechieDelight is another brilliant website with a list of interview questions asked on these topics.


    And by the way, if you feel overwhelmed with tough questions, there's no need to complete each and every thing. It's only normal to get stuck with difficult concepts. I would recommend strengthening your basics and don't waste time on tough questions.
You can move ahead when you will comfortable with the basics and can answer medium level questions. You can come back later for tough questions if you like, but there's no need to do each and everything in one go.

Also you will find most of the solution written in C++ or Java because most product-based companies hiring Software Developer Engineers(SDEs) require you to have a good knowledge of either of the two.

- Heaps and Priority Queue

   This is a wonderful video which would clarify all your concepts regarding heaps, heap sort, priority queues.

{% youtube HqPJF2L5h9U %}

   Yet again, you can practice question from HackerEarth 

[Heaps/Priority Queues Practice Problems Data Structures | HackerEarth](https://www.hackerearth.com/practice/data-structures/trees/heapspriority-queues/practice-problems/)
    
- Graphs and Trees

    There are so many concepts in graphs that it is virtually impossible to know each and every concept. That's why you only to to focus on the core topics related to graphs like DFS, BFS, Connected Components in a Graph, Algorithms like Dijkstra, Floyd-Warshall, Bellman Ford (Shortest Path Algoriths), Kruskal and Prims (Minimum Spanning Tree), Traversing Directed Acyclic Graph(DAG), Disjoint Set Union(DSU).

    [Algorithm Gym :: Graph Algorithms - Codeforces](https://codeforces.com/blog/entry/16221)

    The above Codeforces blog is very detailed but useful list of algorithms along with their implementation and time complexity for graphs and trees. You only need to check for the above mentioned algorithms, since there are really advanced concepts mentioned as well.

    - Bonus: Collection of question for you to sharpen your knowledge of graphs and trees:
       - Easy:

            [Path Sum - LeetCode](https://leetcode.com/problems/path-sum/)

            [Kth Smallest Element in a BST - LeetCode](https://leetcode.com/problems/kth-smallest-element-in-a-bst/)

            [Find the Town Judge - LeetCode](https://leetcode.com/problems/find-the-town-judge/)

       - Medium / Hard:

            [Path with Maximum Probability - LeetCode](https://leetcode.com/problems/path-with-maximum-probability/)

            [Problem - 580C - Codeforces](https://codeforces.com/problemset/problem/580/C)

            [Problem - 862B - Codeforces](https://codeforces.com/problemset/problem/862/B)

            [Problem - 1167C - Codeforces](https://codeforces.com/problemset/problem/1167/C)

            [Problem - 510B - Codeforces](https://codeforces.com/problemset/problem/510/B)

            [Cheapest Flights Within K Stops - LeetCode](https://leetcode.com/problems/cheapest-flights-within-k-stops/)

If you have made it this far, Kudos to you 🙂  
![Alt Text](https://media.giphy.com/media/lEVZJzy4w15qE/giphy.gif)

You are now more than prepared to face graph and tree based problems for your interviews.  

Thanks for reading! Stay tuned