• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 10 páginas
Examen

Cmput 204 Final Exam Solved 2023/2024 Graded A+ Best For Revision.

Document preview thumbnail
Vista previa 2 fuera de 10 páginas

CMPUT204: Introduction to Algorithms Final Exam • This exam has 5 problems, each is worth 25pts. • You may answer all 5 problems, but your grade will be composed of the best 4 answers. • Closed books. • You may use a scientific calculator. • Collaborations of any kind are strictly forbidden. • Note: All logarithms are in base 2 unless specified otherwise. • You can use the fact that H(n) = Σn i=1 1 = ln n + O(1) without proving it. lOMoAR cPSD| 3 Problem 1. (25 pts) Describe the QuickSort algorithm for sorting n elements given in an array A. Prove its correctness, and analyze its runtime in both the best-case and the worst-case. You may assume that you are given a Partition function that operates deterministically in the following fashion. Its input is an array A and two indices p r. It permutes A and returns an index s such that when it halts all elements in A[p, ..., s − 1] are ≤ A[s]; and all elements in A[s + 1, ..., r] are A[s]. Moreover, this A[s], which we refer to as the pivot, was originally the last elements in A[p, ..., r]. You may assume Partition is correct, makes no more than r − p key comparisons and operates in time Θ(r − p) without proving it. Answer. See answers to the midterm. lOMoAR cPSD| 4 Problem 2. (25 pts) The Max-Bottleneck Paths Problem: Given a weighted undirected graph with nonnegative weights, suppose the weights represents the max-capacity of a message sent along an edge. (Alternatively, the edges are roads and the weights are the heights of the bridges above these roads.) Thus, the bottleneck along a path v0, v1, ..., vk is min1≤i≤k{w(vi−1, vi)}. A max-bottleneck path between u and v is a path whose bottleneck is the largest among all paths connecting u and v. (i) (15 pts) Suppose we revise init’() and relax’() to the following functions. init’(s) foreach v ∈ V (G) do v.b ← 0 s.b ← ∞ relax’(u,v) if (v.b min{u.b, w(u, v)}) then v.b ← min{u.b, w(u, v)} Show that any algorithm that only accesses the bottle-neck estimation b via init’() and relax’() always uses lower bounds on the bottleneck. That is, show that for every vertex u, at any point of the algorithm it must hold u.b ≤bottleneck(s, u). Deduce that once such an algorithm sets u.b =bottleneck(s, u) then u.b is never changed from that point on. (ii) (10 pts) Given a start vertex s, adjust Dijkstra’s algorithm to find the max-bottleneck path from s to any other node in V (G). (Use the adjusted init’() and relax’() functions.) Argue the correctness of your algorithm. What’s the runtime of your algorithm? Answer. See answers to HW5 when published.

Vista previa del contenido

lOMoAR cPSD| 12286418




lOMoAR cPSD| 12286418




CMPUT 204 FINAL EXAM
SOLVED 2023/2024 GRADED
A+ BEST FOR REVISION.




1

, lOMoAR cPSD| 12286418




CMPUT204: Introduction to Algorithms
Final Exam
Instructions.
• This exam has 5 problems, each is worth 25pts.
• You may answer all 5 problems, but your grade will be composed of the best 4 answers.
• Closed books.
• You may use a scientific calculator.
• Collaborations of any kind are strictly forbidden.
• Note: All logarithms are in base 2 unless specified otherwise.
• You can use the fact that H(n) = Σ 1i = ln n + O(1) without proving it.
n
i=1




2

Información del documento

Subido en
8 de diciembre de 2023
Número de páginas
10
Escrito en
2023/2024
Tipo
Examen
Contiene
Preguntas y respuestas
$5.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

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.
onlinetutor2025
3.8
(18)
Vendido
257
Seguidores
218
Artículos
856
Última venta
3 días hace



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