6ehw3 - Consider the maze shown below. We try to find a...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
National Taiwan University Handout #15 Department of Electrical Engineering December 10, 2009 Algorithms, Fall 2009 Yao-Wen Chang Name: Student ID: Web ID: Problem 1. (15 pts total) A group of n girls and n boys are attending a dance class. The instructor wants to pair each girl with a boy in such a way that the sum of the absolute value of the height differences between partners is minimized. (a) (10 pts) Let A be a tallest girl in the class (there could be a tie), and let B be a tallest boy. Prove that there is an optimal pairing in which A is paired with B . (b) (5 pts) Based on the result of part (a), give an algorithm for computing an optimal pairing. What is the time complexity of your algorithm? Problem 2. (15 pts total)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Consider the maze shown below. We try to find a shortest path from s to t . Formulate this problem as a graph-search problem and give an efficient algorithm for this problem. s t Problem 3. (15 pts total) Apply the accounting method of the amortized analysis to show that the BUILD-HEAP procedure runs in O ( n ) time. (a) (10 pts) Suppose we put $3 on each node initially. Prove by induction that immediately after calling HEAPIFY( A,i ), the total credit of all the nodes in the subtree rooted at A [ i ] is greater than or equal to h + 1, where h is the height of A [ i ]. (b) (5 pts) Finish the proof that the BUILD-HEAP procedure runs in O ( n ) time....
View Full Document

This note was uploaded on 01/01/2011 for the course EE 5503 taught by Professor Yao-wenchang during the Fall '09 term at National Taiwan University.

Ask a homework question - tutors are online