Hw3_006 - Analysis of Algorithm Homework 3 Due in class on Friday ‐ Feb 25th 2011 Your solutions should be complete and concise MUST has your

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Analysis of Algorithm Homework 3 Due in class on Friday ‐ Feb. 25th, 2011 Your solutions should be complete and concise, MUST has your name (last name followed by first name), section number, 8‐digit UFID, clearly typed or handwritten on it. Show your work for all problems to get full credit. You will be graded exactly by what you write in your homework paper(s). Please do not copy the answers from the solution (if any). Also, do not copy the solution from your friends/classmates. Doing so, if detected, will be considered CHEATING. NO late submissions will be accepted. On‐Campus Students: Turn a hardcopy (stapled) in class, before class begins. NO electronic submissions for On‐Campus students will be accepted. EDGE Students: Submit through email (cot5405sp11[AT]gmail[DOT]com) by 3:00pm on Tuesday March 1st 2011. Any questions regarding the assignment problems should be directed to TA office hours or cot5405sp11[AT]gmail[DOT]com. Inquires to the TA cise emails will be ignored. All the following problems are from the textbook CLRS (3rd edition). Solving wrong problems by any mean will get NO credits. Whenever you are asked to give an algorithm for a problem, I expect you to do all of the following: 1. Provide a concise description of your algorithm followed by the pseudocode. 2. Prove the correctness of your algorithm, that is, the algorithm outputs an optimal solution. 3. Give the asymptotic time complexity of the algorithm and prove it. Do all the following problems, each problem is 20 points. Question 1. There is a group of n people with speeds s1, …, sn. They have a conference that starts soon and they must all cross a bridge to get there. All n people begin on the same side of the bridge. It is nighttime and there is only one flashlight. A maximum of two people can cross at one time. Any party who crosses, either 1 or 2 people, must have the flashlight with them. The flashlight must be walked back and forth, it cannot be thrown. A pair must walk together at the rate of the slower man’s race. Provide a schedule to get all these people across the bridge in a fastest way. Prove the correctness and optimality of your method. Analyze the time cost of your schedule. Question 2. Exercises 16.4‐4 (page 443) Question 3. Consider a queue data structure that supports the following four operations. public boolean isEmpty(); public void enqueue(Object item); public Object dequeue() throws EmptyQueueException; public void multiDequeue(int i) throws EmptyQueueException; The first three are standard queue operations and each takes θ(1) time. The multiDequeue operation takes an integer i and dequeues i items (without returning any of them). Any single multiDequeue operation runs in θ(i) time. a. Suppose that it costs $1 of actual time to enqueue an item, and $1 of actual time to dequeue a single item and possibly return it or throw an exception. Assign an amortized cost to each of the three operations enqueue, dequeue, and multiDequeue, such that your bank balance will never become negative. For full marks, give the smallest possible amortized costs. enqueue: $ dequeue: $ multiDequeue: $ b. Explain why your amortized values are correct (i.e. why the bank balance will never be negative). Hint: what is the relationship between the queue and the number of dollars in the bank? c. Suppose that instead of multiDequeue, we have a different operation: public void multiEnqueue(Object item, int i); which enqueues i copies of item to the queue, at a cost of i dollars of actual time. Can we prove that the amortized cost of every queue operation is in O(1)? Why or why not? Question 4. Problems 22‐2 Articulation points, bridges and bi‐connected components (page 621‐622) Question 5. The minimum bottleneck spanning tree (MBST) is a spanning tree that seeks to minimize the most expensive edge in the tree. More specifically, for a tree T over a graph G, we say that e is a bottleneck edge of T if it is an edge with maximum cost in T. Then, the tree T is a minimum bottleneck spanning tree if T is a spanning tree and there is no other spanning tree of G with a cheaper bottleneck edge. (a) Assume you are given a graph G and a weight w and that G has n nodes and m edges. Give a simple O(n+m) time algorithm that determines if there is a MBST with bottleneck edge with cost no more than w. (b) Is a MBST for a graph G always a minimum spanning tree for G? If so, prove it. If not, give a counter example. (c) Is a minimum spanning tree for a graph G always a MBST for G? If so, prove it. If not, give a counter example. ...
View Full Document

This note was uploaded on 01/15/2012 for the course COT 5405 taught by Professor Ungor during the Fall '08 term at University of Florida.

Ask a homework question - tutors are online