Learn C++ Online

Graph representations (part 2)

On this page
This lesson contains approximately 18 minutes of video content.

Adjacency-list representation

Graph representation alternatives revisited

Questions

Q1

QGraph representations (part 2), Q1

This question is ungraded.

If a graph has four vertices, what is the total number of elements stored across the adjacency lists?

Q2

QGraph representations (part 2), Q2

This question is ungraded.

Given the following adjacency list of an undirected graph,

Node : Adjacency List
   1 : 2,3,4
   2 : 1,3,4
   3 : 1,2
   4 : 1,2

how many neighbors does vertex 3 have?

Q3

QGraph representations (part 2), Q3

This question is ungraded.

Given the following adjacency list of an undirected graph,

Node : Adjacency List
   1 : 2,3,4
   2 : 1,3,4
   3 : 1,2
   4 : 1,2

what is the length of the shortest path (in number of edges) from vertex 3 to vertex 4?