资源预览内容
第1页 / 共3页
第2页 / 共3页
第3页 / 共3页
亲,该文档总共3页全部预览完了,如果喜欢就下载吧!
资源描述
Introduction to AlgorithmsSeptember 7, 2005 Massachusetts Institute of Technology6.046J/18.410J Professors Erik D. Demaine and Charles E. LeisersonHandout 5 Problem Set 1 MIT students: This problem set is due in lecture on Wednesday, September 21, 2005. The homework lab for this problem set will be held 24P.M. on Sunday, September 18, 2005. Reading: Chapters 14 excluding Section 4.4. Both exercises and problems should be solved, but only the problems should be turned in. Exercises are intended to help you master the course material. Even though you should not turn in the exercise solutions, you are responsible for material covered in the exercises. Mark the top of each sheet with your name, the course number, the problem number, your recitation section, the date and the names of any students with whom you collaborated. You will often be called upon to “give an algorithm” to solve a certain problem. Your write-up should take the form of a short essay. A topic paragraph should summarize the problem you are solving and what your results are. The body of the essay should provide the following: 1. A description of the algorithm in English and, if helpful, pseudo-code. 2. At least one worked example or diagram to show more precisely how your algorithm works. 3. A proof (or indication) of the correctness of the algorithm. 4. An analysis of the running time of the algorithm. Remember, your goal is to communicate. Full credit will be given only to correct solutions which are described clearly. Convoluted and obtuse descriptions will receive low marks. Exercise 1-1.Do Exercise 2.3-6 on page 37 in CLRS. Exercise 1-2.Do Exercise 3.1-6 on page 50 in CLRS. Exercise 1-3.Do Exercise 3.2-4 on page 57 in CLRS. Exercise 1-4.Do Problem 4.3-4 on page 75 of CLRS. Problem 1-1.Asymptotic Notation For each of the following statements, decide whether it is always true, never true, or sometimes true for asymptotically nonnegative functions ? and ? . If it is always true or never true, explain why. If it is sometimes true, give one example for which it is true, and one for which it is false. 2Handout 5: Problem Set 1 (a) ? ? ? (b) ? ? ? ? ? ? (c) ? ?!?“?#?$%?!?“?#? (d) ?=?“;= ? (c) . ? . ?“6?5?5A (d) . ?“? . ?CB?D%?;=8?“D%?“? (j) . ?“? B ? . ? B ?“? 143838? Problem 1-3.Unimodal Search An array QSR 1?TUT#?WV is unimodal if it consists of an increasing sequence followed by a decreasing sequence, or more precisely, if there is an index XZY 185*UTUTT_?I such that a QSRcb Ved QSRcb 1V for all 1f/ b d X , and a QSRcb Veg QSRcb 1V for all X / b dD? . In particular, QSRcX V is the maximum element, and it is the unique “locally maximum” element surrounded by smaller elements (QhRiX Oj1V andQhRiX 1V ). (a) Giveanalgorithmtocomputethemaximumelementofa unimodalinputarray QhR 1?TUT?kV in -?;=?“? time. Prove the correctness of your algorithm, and prove the bound on its running time. A polygon is convex if all of its internal angles are less than 14l?3nm (and none of the edges cross each other). Figure 1 shows an example. We represent a convex polygon as an arrayo R 1?TUT?kV where each element of the array represents a vertex of the polygon in the form of a coordinate pair ?qpe_rs? . We are told thato-R 1V is the vertex with the minimum p coordinate and that the verticeso R 1?TUT#?WV are ordered counterclockwise, as in the fi gure. You may also assume that the p coordinates of the vertices are all distinct, as are the r coordinates of the vertices. Handout 5: Problem Set 13 tfucvw tfucxw tfucyw tfuz#w t|ucw tfucw tfuUw tfucw tfuiw Figure 1: An example of a convex polygon represented by the array o R 1?TUT_V . o R 1V is the vertex with the minimum p -coordinate, andoR 1?TUT#V are ordered counterclockwise. (b) Give an algorithm to fi nd the vertex with the maximum p coordinate in ?; ? time. (c) Give an algorithm to fi nd the vertex with the maximum r coordinate in ?; ? time.
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号