100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Examen

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

Puntuación
-
Vendido
-
Páginas
5
Grado
A+
Subido en
12-05-2025
Escrito en
2024/2025

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










Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Información del documento

Subido en
12 de mayo de 2025
Número de páginas
5
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas

Vista previa del contenido

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.
$14.49
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
Topscorer london
Ver perfil
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
110
Miembro desde
5 año
Número de seguidores
13
Documentos
454
Última venta
11 horas hace
Top Scorer

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

4.3

24 reseñas

5
16
4
3
3
3
2
0
1
2

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes