Graph cheatsheet for coding interviews | Tech Interview Handbook
A graph is a structure containing a set of objects (nodes or vertices) where there can be edges between these nodes/vertices. Edges can be directed or undirected and can optionally have values (a weighted graph). Trees are undirected graphs in which any two vertices are connected by exactly one edge and there can be no cycles in the graph. Graphs are commonly used to model relationship between unordered entities, such as Be familiar with the various graph representations, graph search algorithms and their time and space complexities. You can be given a list of edges and you have to build your own graph from the edges so that you can perform a traversal on them. The common graph representations are: Using a hash table of hash tables would be the simplest approach during algorithm interviews. It will be rare that you have to use an adjacency matrix or list for graph questions during interviews. In algorithm interviews, graphs are commonly given in the input as 2D matrices where cells are
👋 Hi there, I'm Yangshun, an ex-Meta Staff Engineer, author of this handbook and Blind 75. Follow me on LinkedIn for Software Engineering advice and interview tips! A graph is a structure containing a set of objects (nodes or vertices) where there can be edges between these nodes/vertices. Edges can be directed or undirected and can optionally have values (a weighted graph). Trees are undirected graphs in which any two vertices are connected by exactly one edge and there can be no cycles in the graph. Graphs are commonly used to model relationship between unordered entities, such as…
saved by
related reading
- GitHub - ombharatiya/FAANG-Coding-Interview-Questions: A curated List of Coding Questions Asked in FAANG Interviewsgithub.com
- CS Academycsacademy.com
- A Gentle Introduction to Graph Neural Networksdistill.pub
- Breadth-first search - Wikipediaen.wikipedia.org
- Depth-first search - Wikipediaen.wikipedia.org
- What are graph algorithms? A comprehensive guideneo4j.com
- Google Maps–it’s just one big graph : Networks Course blog for INFO 2040/CS 2850/Econ 2040/SOC 2090blogs.cornell.edu
- Foundations Of Data Structures And Algorithms | Pier Paolo Ippolitopierpaolo28.github.io
- Visualizing Algorithmsbost.ocks.org
- [Feature] Add a way to detect a Tree & Implement faster diameter algorithm · Issue #1359 · sbromberger/LightGraphs.jl · GitHubgithub.com
- Big-O Algorithm Complexity Cheat Sheet (Know Thy Complexities!) @ericdrowellbigocheatsheet.com
- SemanticGraph (Stanford CoreNLP API)nlp.stanford.edu