• Verkeerd document? Gratis ruilen
  • Geschreven door studenten die geslaagd zijn
  • Direct beschikbaar na je betaling
  • Online lezen of als PDF
Verkopen
Kies je studieland
Kies je taal
Document preview thumbnail
Voorbeeld 3 van de 24 pagina's
Tentamen (uitwerkingen)

Module 4- Advanced Data Structures - Graph Algorithms & FFT Notes

Document preview thumbnail
Voorbeeld 3 van de 24 pagina's

Module 4- Advanced Data Structures - Graph Algorithms & FFT Notes

Voorbeeld van de inhoud

lOMoARcPSD|44613495




Advance Data Structures Module 4 Notes


Data Structure and Algorithms for Problem solving (Visvesvaraya Technological
University)




Scan to open on Studocu




Studocu is not sponsored or endorsed by any college or university
Downloaded by Samuel Wachira ndiang'ui ()

, lOMoARcPSD|44613495




Data Structures & Algorithms for Problem Solving
Module – 4




Graph Algorithms and Polynomials with FFT

1. Graph Algorithms

Bellman-Ford Algorithm

Definition: The Bellman-Ford algorithm is a graph algorithm that computes the shortest
paths from a single source vertex to all other vertices in a weighted graph. It can handle
graphs with negative weight edges.

Algorithm Steps:

1. Initialize the distance to the source vertex as 0 and all other vertices as infinity.

2. For each vertex, relax all edges. This means for each edge ( (u, v) ) with weight ( w ), if
( distance[u] + w < distance[v] ), update ( distance[v] ).

3. Repeat the relaxation process for ( V-1 ) times, where ( V ) is the number of vertices.

4. Check for negative weight cycles by performing one more relaxation. If any distance
can still be updated, a negative cycle exists.

Complexity:

 Time Complexity: (O(V \cdot E)), where (V) is the number of vertices and (E) is the
number of edges.

 Space Complexity: (O(V)) for storing distances.



Single Source Shortest Paths in a DAG

Definition: In a Directed Acyclic Graph (DAG), the shortest paths from a single source can be
found using topological sorting.

Algorithm Steps:

1. Perform a topological sort of the DAG.




Downloaded by Samuel Wachira ndiang'ui ()

, lOMoARcPSD|44613495




2. Initialize the distance to the source vertex as 0 and all other vertices as infinity.

3. Process each vertex in topological order:

 For each outgoing edge ( (u, v) ) with weight ( w ), if ( distance[u] + w <
distance[v] ), update ( distance[v] ).

Complexity:

 Time Complexity: (O(V + E)) due to topological sorting and relaxation.

 Space Complexity: (O(V)) for storing distances.



Johnson’s Algorithm for Sparse Graphs

Definition: Johnson’s algorithm finds the shortest paths between all pairs of vertices in a
sparse graph, even with negative weights, but without negative cycles.

Algorithm Steps:

1. Add a new vertex ( q ) connected to all other vertices with zero-weight edges.

2. Use the Bellman-Ford algorithm to find the shortest paths from ( q ) to all other
vertices. If a negative cycle is detected, terminate.

3. Reweight the edges using the formula: ( w'(u, v) = w(u, v) + h[u] - h[v] ), where ( h ) is
the distance from ( q ).

4. Use Dijkstra’s algorithm for each vertex to find the shortest paths in the reweighted
graph.

Complexity:

 Time Complexity: (O(V^2 \log V + V E)) for sparse graphs.

 Space Complexity: (O(V + E)).



Flow Networks and Ford-Fulkerson Method

Definition: The Ford-Fulkerson method computes the maximum flow in a flow network using
augmenting paths.

Algorithm Steps:

1. Initialize the flow in all edges to 0.

2. While there exists an augmenting path from the source to the sink, increase the flow
along this path.




Downloaded by Samuel Wachira ndiang'ui ()

Documentinformatie

Studie
Geüpload op
25 februari 2026
Aantal pagina's
24
Geschreven in
2025/2026
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden
€20,30

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

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.
Writewise
3,4
(5)
Verkocht
57
Volgers
7
Items
1813
Laatst verkocht
2 weken geleden

Echte notities, van echte studenten
Elk document op Stuvia is geschreven door een medestudent die hetzelfde vak deed. Zo leer je van iemand die het al heeft gehaald.



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

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen