Join 75,000+ students acing their exams with Studygenie
Unlimited practice
Flashcards, multiple choice and written questions, as many as you want.
Study sets in seconds
Turn your notes and files into a set with AI.
See your progress
Always know what you've learned and what's left.
Questions in this set (10)
difference between undirected vs directed graph?
undirected graph, the edge (x, y) is the same as the edge (y, x). for a directed graph, (x, y) and (y, x) are distinct
whats the difference between simple and non-simple graph?
simple graph, at most 1 edge connects any 2 vertices. For a non-simple graph, any 2 vertices can have more than 1 edges
whats a path?
any sequence of vertices in a graph
whats a cycle?
a path where the first and last vertices are the same and no edges are repeated
whats a simple cycle?
a cycle where no vertices are repeated
whats acyclic?
a graph that is not a cycle
difference between multigraph vs pseudograph?
multigraph permits multiple edges between vertices but loops. pseudograph permits bot multiple edges and loops
what are the 2 implementation of graph?
adjacency matrices and adjacency lists
whats are the pros and cons of adjacency matrices?
pros:
simple to create and use
checking if there is an edge between x and y is an O(1) operation by accessing A[x][y]
cons:
space complexity is O(|V|^2) when matrix is sparse
have to iterate every entry in the nth row even if there's no edges that lead to it
what are the pros/cons of adjacency lists?
pros:
no wasted space on nonexistent edges
no wasted steps if need to iterate over all edges that lead out of node
cons:
no good way to determine the edges that lead into node
might have to iterate through list to check if there exists an edge between x and y