100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4.2 TrustPilot
logo-home
Tentamen (uitwerkingen)

University of Texas, ECE ALGORITHMS, Homework9_Solution. All answers are correct.

Beoordeling
-
Verkocht
-
Pagina's
5
Cijfer
A+
Geüpload op
12-05-2025
Geschreven in
2024/2025

Homework9_Solution, University of Texas, ECE ALGORITHMS. All answers are 100% correct.

Instelling
Vak









Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
12 mei 2025
Aantal pagina's
5
Geschreven in
2024/2025
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

Voorbeeld van de inhoud

EE360C: Algorithms
University of Texas at Austin Homework #9
Dr. Christine Julien, Dr. Vallath Nandakumar Due Date: April 12, 2018


Homework #9
You should try to solve these problems by yourself. I recommend that you start early and get help
in office hours if needed. If you find it helpful to discuss problems with other students, go for it.
You do not need to turn in these problems. The goal is to be ready for the in class
quiz that will cover the same or similar problems.

Instructions: For all the following problems, give the recurrence relation, prove your
optimal substructure is correct and calculate the runtime.

Problem 1: Longest Paths
Given an undirected graph G = (V, E) with positive edge weights we for each edge e ∈ E, give
a dynamic programming algorithm to compute the longest path in G from a given source s that
contains at most n edges.
(Hint: Let A[v, k] denote the weight of the longest path from s to node v of at most k edges).
Solution
Initialize A[v, 1] = wsv if (s, v) ∈ E, A[v, 1] = 0 otherwise.
A[v, k] = max{A[v, k − 1], maxu:(u,v)∈E {wuv + A[u, k − 1]}}
Correctness: The problem has optimal substructure. Take a maximum weight path from s
to t in atmost k steps. If this path is {s, u1 , u2 , · · · , uj , t}, then the maximum weight path
from u1 to t in atmost k − 1 steps must be {u1 , u2 , · · · , uj , t}.
Perform induction on k. The base case k = 1 is trivial. Assume it is optimal for k. To
prove optimality for k + 1 using contradiction, assume that the algorithm is not optimal.
This implies that there exists a u ∈ V such that the maximum weight path to u in k steps is
greater than A[u, k]. But since the algorithm is optimal for k, this is impossible. Therefore
the algorithm is optimal for k + 1.
Running time: Any path can have atmost |V | steps. For any k, the cost is O(|V | + |E|)
since for each node v the cost of computing A[v, k] is proportional to 1 + degree(v). Thus
the total runtime is O(|V |(|E| + |V |)).

Problem 2: Moving in a Grid
Imagine that you are placed on a grid with n spaces in every row and n spaces in every column.
You can start anywhere along the bottom row of the grid, and you must move to the top row of
the grid. Each time you move, you can either move directly up (staying in the same column, but
moving up a row), up and to the left (moving over one column and up one row), or up and to the
right (moving over one column and up one row). You cannot move up and to the left if you are in
the leftmost row, and you cannot move up and to the right if you are in the right most row.
Each time you move, you are either paid or pay; that is, every legal move from square x to
square y is assigned a real value p(x, y). Sure, p(x, y) can also be 0.
Give a dynamic programming algorithm to compute your sequence of moves to receive the
maximum payoff to move from the bottom of the grid to the top of the grid. (Your maximum
payoff may be negative.) You must calculate the value of the optimal solution (i.e., the payoff) and

, Homework #9: April 12, 2018 2


the solution itself (i.e., the sequence of moves). Again, you can start at any square in the bottom
row and end in any square in the top row.

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.
Topscorer london
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
110
Lid sinds
5 jaar
Aantal volgers
13
Documenten
454
Laatst verkocht
17 uur geleden
Top Scorer

Helping all Students fulfill their educational, career and personal goals.

4,3

24 beoordelingen

5
16
4
3
3
3
2
0
1
2

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 Bancontact, iDeal of creditcard en download je PDF-document meteen.

Student with book image

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

Alisha Student

Veelgestelde vragen