flâneur

Graph cheatsheet for coding interviews | Tech Interview Handbook

techinterviewhandbook.org · 1,427 words · saved by 1 readers

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