Docsity

Midterm 2 Practice Questions - Computer Graphics | ECS 175, Assignments of Computer Graphics

Toggle sidebar
bg1
ECS175: Algorithm Analysis and Design
Practice Midterm 2
1. A graph can include many negative-weight cycles. In the arbitrage problem from
Homework 5, you gave an algorithm to find one negative-weight cycle. It would would
be more profitable to find all of the negative-weight cycles, but unfortunately on a
worst-case graph this might require time Ω(2n), where n=|V|. Describe how to
construct such a worst-case graph, for any given n.
1
pf3

Partial preview of the text

Download Midterm 2 Practice Questions - Computer Graphics | ECS 175 and more Assignments Computer Graphics in PDF only on Docsity!

ECS175: Algorithm Analysis and Design

Practice Midterm 2

  1. A graph can include many negative-weight cycles. In the arbitrage problem from Homework 5, you gave an algorithm to find one negative-weight cycle. It would would be more profitable to find all of the negative-weight cycles, but unfortunately on a worst-case graph this might require time Ω(2n), where n = |V |. Describe how to construct such a worst-case graph, for any given n.
  1. We implemented Dijkstra’s algorithm using a heap for the priority queue. One can also implement a priority queue simply as a linked list, with the elements sorted in order of priority. To perform an INSERT (v, Q)or DECREASE-KEY(v, Q), we have to locate v in the list. a) What are the asymptotic times required for the operations EXTRACT-MIN(Q), INSERT(v, Q), and DECREASE-KEY(v, Q) when the priority queue is implemented as a linked list? How about when the priority queue is implemented as a heap?

b) What is the overall running time of Dijkstra’s algorithm with the queue implemented as a linked list?