• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 1 out of 2 pages
Exam (elaborations)

CS 6515 Graph Algorithms Test Questions and Answers Solved Correctly

Document preview thumbnail
Preview 1 out of 2 pages

CS 6515 Graph Algorithms Test Questions and Answers Solved Correctly DFS outputs - Answerspre array, post array, ccnum array, prev array BFS outputs - Answersdist array, prev array Explore outputs - Answersvisited array. When to use Dijkstra's? - AnswersWorks for both directed and undirected graphs. Must have only non-negative edge weights. Dijkstra's outputs - Answersdist array, prev array Dijkstra's runtime? - AnswersO((n+m) log n) log n is from using the min heap (to get the lowest cost weight) When to use Bellman Ford? - AnswersUse when there is a graph with negative edge weights. Gives us the shortest path from s to every other vertex v. Slower than Dijkstra's algorithm. Dijkstra's was O((n+m)logn), but this is O(n*m). Can also be used to detect negative weight cycles IF the cycle is reachable from sources. Bellman ford runtime - AnswersO(n*m) Remember, this uses a dynamic programming table. Will have found the shortest path distances after n - 1 iterations. If the distances keep updating, there is a negative weight cycle. Floyd Warshall output - AnswersReturns an n by n matrix of shortest path costs between EVERY pair of vertices. Floyd Warshall runtime - AnswersO(n^3) When to use SCC algorithm? - AnswersOnly useful for directed graphs. Use to get a metagraph of connected components. Each SCC is represented as a single node. The resulting metagraph is always a DAG. SCC algorithm time complexity - AnswersO(n+m) Uses topological sort (O(n+m)) on the reverse graph Complexity to find an MST - AnswersO(m log n) for both Kruskal's and for Prim's When to use Kruskal's or Prim's? - AnswersTo find the MST of an undirected graph Kruskal's vs. Prim's? Differences in approach? - AnswersKruskal's greedily takes the cheapest edges and adds them to our MST (if they don't create cycles). Checking for cycles is accomplished via the union find data structure. Prim's is similar to Dijkstra's, looking at nodes, and adds the lightest edge to connect between the subtree and any unconnected node. Ford Fulkerson main steps - Answers1. Start with f_e = 0 for all edges 2. Build the residual network for current flow. This means backward edges for edges that are

Content preview

CS 6515 Graph Algorithms Test Questions and Answers Solved Correctly

DFS outputs - Answerspre array, post array, ccnum array, prev array

BFS outputs - Answersdist array, prev array

Explore outputs - Answersvisited array.

When to use Dijkstra's? - AnswersWorks for both directed and undirected graphs. Must have only non-
negative edge weights.

Dijkstra's outputs - Answersdist array, prev array

Dijkstra's runtime? - AnswersO((n+m) log n)

log n is from using the min heap (to get the lowest cost weight)

When to use Bellman Ford? - AnswersUse when there is a graph with negative edge weights. Gives us
the shortest path from s to every other vertex v. Slower than Dijkstra's algorithm. Dijkstra's was
O((n+m)logn), but this is O(n*m). Can also be used to detect negative weight cycles IF the cycle is
reachable from sources.

Bellman ford runtime - AnswersO(n*m)

Remember, this uses a dynamic programming table. Will have found the shortest path distances after n -
1 iterations. If the distances keep updating, there is a negative weight cycle.

Floyd Warshall output - AnswersReturns an n by n matrix of shortest path costs between EVERY pair of
vertices.

Floyd Warshall runtime - AnswersO(n^3)

When to use SCC algorithm? - AnswersOnly useful for directed graphs. Use to get a metagraph of
connected components. Each SCC is represented as a single node. The resulting metagraph is always a
DAG.

SCC algorithm time complexity - AnswersO(n+m)

Uses topological sort (O(n+m)) on the reverse graph

Complexity to find an MST - AnswersO(m log n) for both Kruskal's and for Prim's

When to use Kruskal's or Prim's? - AnswersTo find the MST of an undirected graph

Kruskal's vs. Prim's? Differences in approach? - AnswersKruskal's greedily takes the cheapest edges and
adds them to our MST (if they don't create cycles). Checking for cycles is accomplished via the union find
data structure.

Document information

Uploaded on
July 29, 2025
Number of pages
2
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$10.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
joshuawesonga22
3.6
(15)
Sold
143
Followers
2
Items
15836
Last sold
9 hours ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions