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.
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
Binary Search Tree Tutorials & Notes | Data Structures | HackerEarth
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
Binary Search Tree (BST) - Interview Questions & Practice Problems
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.
Yet again, you can practice question from HackerEarth
Heaps/Priority Queues Practice Problems Data Structures | HackerEarth
-
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
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:
-
Medium / Hard:
-
-
If you have made it this far, Kudos to you 🙂
You are now more than prepared to face graph and tree based problems for your interviews.
Thanks for reading! Stay tuned
Top comments (0)