100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

Algorithms - Graph Algorithms Exam Questions and Answers Fully Solved Latest Version

Rating
-
Sold
-
Pages
4
Grade
A+
Uploaded on
03-08-2025
Written in
2025/2026

Algorithms - Graph Algorithms Exam Questions and Answers Fully Solved Latest Version How to get the connected components in undirected graphs? - AnswersRun DFS and keep track of component number What is the input and output of DFS when run on an undirected graph? - AnswersThe input is a graph of vertices and edges in adjacency list representation, and the output is the list of vertices labelled by connected components What does the Explore subroutine do when called by DFS? - AnswersThe DFS algorithm itself increments the connected component number. The explore subroutine sets each vertex to the current value of the connected component number and sets the visited flag to true on the vertex. It then repeats this routine on every vertex that it can reach from its current vertex. How do you find a path between connected vertices on undirected graphs? - AnswersUpdate the DFS and Explore subroutines to store a "prev" or "previous" variable for each vertex. DFS initializes the value to null for all vertices, and the explore sub routine updates this value after calling itself on each vertex that is reachable from the one it started from - sets it to the value of the input vertex How do you obtain connectivity info on directed graphs? - AnswersUpdate the DFS and Explore subroutines to use a "clock" variable that starts at 1. Each time the explore subroutine is run, it sets the pre order number to the current value of the clock and then increments the clock. When it finishes one full execution, it sets the post order number to the current value of the clock and then increments it. Why increment the clock in the Explore subroutine? - AnswersSo that no two vertices have the same pre order or post order number What are the different types of edges in a DFS graph? - AnswersTree edges, back edges, forward edges, cross edges How do the different types of edges in a DFS graph arise? - AnswersAn edge to a vertex that has already been explored. For back edges, the post order number of the ancestor is lower than that of the descendant. In all other edges, the ancestor has a higher post order number. In cross-edges, there is no apparent ancestor-descendent relation which can be observed with the pre order numbers. How can you determine a graph has a cycle using its DFS tree? - AnswersGraph G has a cycle if and only if its DFS tree has a back edge What is a DAG? - AnswersDirected Acyclic Graph (has no back edges) What is meant by a topological sorting of a DAG? - AnswersAn order of the vertices of the DAG such that all edges go from lower to higher How do you topologically sort a DAG? - AnswersRun DFS on DAG G. Since there are no back edges, all edges from z to w will have a higher post order number on z than w. After running DFS, order the vertices by decreasing post order number. What is the runtime of topologically sorting a DAG? - AnswersO(n+m) Define a source vertex in terms of edges and post order numbers - AnswersNo incoming edges and highest post-order number Define a sink vertex in terms of edges and post order numbers - AnswersNo outgoing edges and lowest post-order number Wen are two vertices v and w strongly connected? - AnswersWhen there is a path from v to w and w to v. Path implies that multiple edges can be involved.

Show more Read less
Institution
Algorithms - Graph Algorithms
Course
Algorithms - Graph Algorithms








Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Algorithms - Graph Algorithms
Course
Algorithms - Graph Algorithms

Document information

Uploaded on
August 3, 2025
Number of pages
4
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

Algorithms - Graph Algorithms Exam Questions and Answers Fully Solved Latest Version 2025-2026

How to get the connected components in undirected graphs? - AnswersRun DFS and keep track of
component number

What is the input and output of DFS when run on an undirected graph? - AnswersThe input is a graph of
vertices and edges in adjacency list representation, and the output is the list of vertices labelled by
connected components

What does the Explore subroutine do when called by DFS? - AnswersThe DFS algorithm itself increments
the connected component number. The explore subroutine sets each vertex to the current value of the
connected component number and sets the visited flag to true on the vertex. It then repeats this routine
on every vertex that it can reach from its current vertex.

How do you find a path between connected vertices on undirected graphs? - AnswersUpdate the DFS
and Explore subroutines to store a "prev" or "previous" variable for each vertex. DFS initializes the value
to null for all vertices, and the explore sub routine updates this value after calling itself on each vertex
that is reachable from the one it started from - sets it to the value of the input vertex

How do you obtain connectivity info on directed graphs? - AnswersUpdate the DFS and Explore
subroutines to use a "clock" variable that starts at 1. Each time the explore subroutine is run, it sets the
pre order number to the current value of the clock and then increments the clock. When it finishes one
full execution, it sets the post order number to the current value of the clock and then increments it.

Why increment the clock in the Explore subroutine? - AnswersSo that no two vertices have the same pre
order or post order number

What are the different types of edges in a DFS graph? - AnswersTree edges, back edges, forward edges,
cross edges

How do the different types of edges in a DFS graph arise? - AnswersAn edge to a vertex that has already
been explored. For back edges, the post order number of the ancestor is lower than that of the
descendant. In all other edges, the ancestor has a higher post order number. In cross-edges, there is no
apparent ancestor-descendent relation which can be observed with the pre order numbers.

How can you determine a graph has a cycle using its DFS tree? - AnswersGraph G has a cycle if and only
if its DFS tree has a back edge

What is a DAG? - AnswersDirected Acyclic Graph (has no back edges)

What is meant by a topological sorting of a DAG? - AnswersAn order of the vertices of the DAG such that
all edges go from lower to higher

How do you topologically sort a DAG? - AnswersRun DFS on DAG G. Since there are no back edges, all
edges from z to w will have a higher post order number on z than w. After running DFS, order the
vertices by decreasing post order number.

Get to know the seller

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.
TutorJosh Chamberlain College Of Nursing
View profile
Follow You need to be logged in order to follow users or courses
Sold
332
Member since
1 year
Number of followers
16
Documents
28211
Last sold
1 day ago
Tutor Joshua

Here You will find all Documents and Package Deals Offered By Tutor Joshua.

3.6

53 reviews

5
18
4
14
3
12
2
0
1
9

Recently viewed by you

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

Frequently asked questions