21 cards · Public · Shuffle

Algorithms - Graph Theory & Shortest Path Algorithms

Master graph theory fundamentals and conquer shortest path algorithms! This comprehensive deck covers graph types, representations, traversals (BFS, DFS), and essential algorithms like Dijkstra's, Bellman-Ford, and Floyd-Warshall, complete with complexities and real-world applications.

Cards in this deck

(21 cards)

Preview terms and definitions before starting your study session.

#1
Term
What is a Graph in Computer Science?
Definition
A graph is a non-linear data structure consisting of a finite set of vertices (or nodes) and a set of edges (or arcs) connecting pairs of vertices. It's formally represented as , where is the set of vertices and is the set of edges.
#2
Term
Distinguish between a Directed and an Undirected Graph.
Definition
An Undirected Graph has edges that are bidirectional, meaning if an edge connects vertex A to vertex B, it also connects B to A. An Directed Graph (or Digraph) has edges with a specific direction, meaning an edge from A to B does not imply an edge from B to A.
#3
Term
What is a Weighted Graph?
Definition
A Weighted Graph is a graph where each edge has an associated numerical value, called a weight or cost. These weights typically represent distances, costs, times, or capacities, and are crucial for algorithms like shortest path.
#4
Term
What are the common terms for the components of a graph?
Definition
The fundamental components are:
  • Vertex (Node): A point or entity in the graph.
  • Edge (Arc): A connection between two vertices.
  • Path: A sequence of distinct vertices where each adjacent pair is connected by an edge.
  • Cycle: A path that starts and ends at the same vertex.
#5
Term
Explain Adjacency Matrix representation for a graph.
Definition
An Adjacency Matrix is a square matrix of size (where is the number of vertices). If there is an edge from vertex to vertex , the entry is 1 (or the weight of the edge); otherwise, it's 0 (or infinity for no edge in weighted graphs).
Space Complexity: .
Time Complexity (Check edge): .
Time Complexity (Find neighbors): .
#6
Term
Explain Adjacency List representation for a graph.
Definition
An Adjacency List is an array of lists where the size of the array is . Each index in the array stores a list of all vertices adjacent to vertex . For weighted graphs, the list stores pairs of (neighbor, weight).
Space Complexity: (where is the number of edges).
Time Complexity (Check edge): for vertex .
Time Complexity (Find neighbors): for vertex .
#7
Term
When would you prefer an Adjacency Matrix over an Adjacency List?
Definition
An Adjacency Matrix is preferred for dense graphs (where is close to ) because it offers edge lookup. It's also simpler for some algorithms that require quick access to any entry, such as Floyd-Warshall.
#8
Term
When would you prefer an Adjacency List over an Adjacency Matrix?
Definition
An Adjacency List is preferred for sparse graphs (where is much smaller than ) due to its lower space complexity compared to . It's also more efficient for iterating over neighbors of a vertex, which is common in BFS and DFS.
Showing 8 of 21 cards in this deck.
Study All Now