This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Algorithms CMSC37000 Final Exam. March 14, 2006 Instructor: L´ aszl´ o Babai Show all your work . Do not use text, notes, or scrap paper. When describing an algorithm in pseudocode, explain the meaning of your variables (in English). This exam contributes 30% to your course grade. Take this problem sheet home. 1. (4 points) Given a digraph G by an array of adjacency lists, find an adjacency list representation of the reverse digraph in linear time. De scribe your algorithm is pseudocode. 2. (12 points) (Segmentation) Consider the list of integers (1 , 2 , . . . , n ). A segment is a contiguous sublist, ( i, i + 1 , . . . , j ) where i ≤ j . A segmentation means splitting up the list into segments. For instance, for n = 8, a possible segmentation is (1 , 2 , 3) , (4) , (5 , 6 , 7 , 8). We are given a triangular array p ( i, j ) (1 ≤ i ≤ j ≤ n ) of segment penalties (real numbers); the “penalty” of segment ( i, . . . , j ) is p ( i, j ). The cost of the segmentation is the sum of the penalties of the segments. In the example, the cost is p (1 , 3) + p (4 , 4) + p (5 , 8). Find, in O ( n 3 ) time, the optimal (mincost) segmentation. Give your algorithm in pseudocode....
View
Full
Document
This note was uploaded on 11/26/2009 for the course CIS 502 taught by Professor Naver during the Spring '09 term at National Tsing Hua University, China.
 Spring '09
 Naver
 Algorithms

Click to edit the document details