Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Tentamen (uitwerkingen)

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

Beoordeling
-
Verkocht
-
Pagina's
4
Cijfer
A+
Geüpload op
03-08-2025
Geschreven 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.

Meer zien Lees minder
Instelling
Algorithms - Graph Algorithms
Vak
Algorithms - Graph Algorithms

Voorbeeld van de inhoud

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.

Geschreven voor

Instelling
Algorithms - Graph Algorithms
Vak
Algorithms - Graph Algorithms

Documentinformatie

Geüpload op
3 augustus 2025
Aantal pagina's
4
Geschreven in
2025/2026
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

€9,71
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF


Ook beschikbaar in voordeelbundel

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
TutorJosh Chamberlain College Of Nursing
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
407
Lid sinds
1 jaar
Aantal volgers
16
Documenten
31240
Laatst verkocht
1 dag geleden
Tutor Joshua

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

3,4

68 beoordelingen

5
23
4
15
3
13
2
1
1
16

Populaire documenten

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Veelgestelde vragen