ImageVerifierCode 换一换
格式:DOCX , 页数:15 ,大小:52.14KB ,
资源ID:25691818      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/25691818.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(计算机算法分析与设计课程综合实验.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

计算机算法分析与设计课程综合实验.docx

1、计算机算法分析与设计课程综合实验算法分析与设计课程综合实验Design and Analysis of Algorithms1 Map Routing要求:Mandatory. 实验目的:Implement the classic Dijkstras shortest path algorithm and optimize it for maps. Such algorithms are widely used in geographic information systems (GIS) including MapQuest and GPS-based car navigation syst

2、ems. 实验内容及要求: Maps. For this assignment we will be working with maps, or graphs whose vertices are points in the plane and are connected by edges whose weights are Euclidean distances. Think of the vertices as cities and the edges as roads connected to them. To represent a map in a file, we list the

3、 number of vertices and edges, then list the vertices (index followed by its x and y coordinates), then list the edges (pairs of vertices), and finally the source and sink vertices. For example, Input6 represents the map below:Dijkstras algorithm. Dijkstras algorithm is a classic solution to the sho

4、rtest path problem. It is described in section 24.3 in CLRS. The basic idea is not difficult to understand. We maintain, for every vertex in the graph, the length of the shortest known path from the source to that vertex, and we maintain these lengths in a priority queue. Initially, we put all the v

5、ertices on the queue with an artificially high priority and then assign priority 0.0 to the source. The algorithm proceeds by taking the lowest-priority vertex off the PQ, then checking all the vertices that can be reached from that vertex by one edge to see whether that edge gives a shorter path to

6、 the vertex from the source than the shortest previously-known path. If so, it lowers the priority to reflect this new information. Here is a step-by-step description that shows how Dijkstras algorithm finds the shortest path 0-1-2-5 from 0 to 5 in the example above. process 0 (0.0) lower 3 to 3841.

7、9 lower 1 to 1897.4process 1 (1897.4) lower 4 to 3776.2 lower 2 to 2537.7process 2 (2537.7) lower 5 to 6274.0process 4 (3776.2)process 3 (3841.9)process 5 (6274.0)This method computes the length of the shortest path. To keep track of the path, we also maintain for each vertex, its predecessor on the

8、 shortest path from the source to that vertex. The files EuclideanGraph.java, Point.java, IndexPQ.java, IntIterator.java, and Dijkstra.java provide a bare bones implementation of Dijkstras algorithm for maps, and you should use this as a starting point. The client program ShortestPath.java solves a

9、single shortest path problem and plots the results using turtle graphics. The client program Paths.java solves many shortest path problems and prints the shortest paths to standard output. The client program Distances.java solves many shortest path problems and prints only the distances to standard

10、output. Your goal. Optimize Dijkstras algorithm so that it can process thousands of shortest path queries for a given map. Once you read in (and optionally preprocess) the map, your program should solve shortest path problems in sublinear time. One method would be to precompute the shortest path for

11、 all pairs of vertices; however you cannot afford the quadratic space required to store all of this information. Your goal is to reduce the amount of work involved per shortest path computation, without using excessive space. We suggest a number of potential ideas below which you may choose to imple

12、ment. Or you can develop and implement your own ideas. Idea 1. The naive implementation of Dijkstras algorithm examines all V vertices in the graph. An obvious strategy to reduce the number of vertices examined is to stop the search as soon as you discover the shortest path to the destination. With

13、this approach, you can make the running time per shortest path query proportional to E log V where E and V are the number of edges and vertices examined by Dijkstras algorithm. However, this requires some care because just re-initializing all of the distances to would take time proportional to V. Si

14、nce you are doing repeated queries, you can speed things up dramatically by only re-initializing those values that changed in the previous query. Idea 2. You can cut down on the search time further by exploiting the Euclidean geometry of the problem, as described in section 21.5 in the book of Algor

15、ithm in C Part V. For general graphs, Dijkstras relaxes edge v-w by updating dw to the sum of dv plus the distance from v to w. For maps, we instead update dw to be the sum of dv plus the distance from v to w plus the Euclidean distance from w to d minus the Euclidean distance from v to d. This is k

16、nown as the A* algorithm. This heuristics affects performance, but not correctness. Idea 3. Use a faster priority queue. There is some room for optimization in the supplied priority queue. You could also consider using a multiway heap as in Sedgewick Program 20.10. Testing. The file usa.txt contains

17、 87,575 intersections and 121,961 roads in the continental United States. The graph is very sparse - the average degree is 2.8. Your main goal should be to answer shortest path queries quickly for pairs of vertices on this network. Your algorithm will likely perform differently depending on whether

18、the two vertices are nearby or far apart. We provide input files that test both cases. You may assume that all of the x and y coordinates are integers between 0 and 10,000.实验类型:Verification.适用对象:Undergraduate for Computer School2 Document Distance Problem要求:Mandatory. 实验目的:Design and implement the d

19、ocument distance problem and optimize it for data. 实验内容及要求: Let D be a text document (e.g. the complete works of William Shakespeare). A word is a consecutive sequence of alphanumeric characters, such as Hamlet or 2007. Well treat all upper-case letters as if they are lower-case, so that Hamlet and

20、hamlet are the same word. Words end at a non-alphanumeric character, so cant contains two words: can and t. The word frequency distribution of a document D is a mapping from words w to their frequency count, which well denote as D(w). We can view the frequency distribution D as vector, with one comp

21、onent per possible word. Each component will be a non-negative integer (possibly zero). The norm of this vector is defined in the usual way:. The inner-product between two vectors D and D is defined as usual. . Finally, the angle between two vectors D and D is defined: This angle (in radians) will b

22、e a number between 0 and since the vectors are non-negative in each component. Clearly, angle(D,D) = 0.0 for all vectors D, and angle(D,D) = / 2 if D and D have no words in common. Example: The angle between the documents To be or not to be and Doubt truth to be a liar is We define the distance betw

23、een two documents to be the angle between their word frequency vectors. The document distance problem is thus the problem of computing the distance between two given text documents. An instance of the document distance problem is the pair of input text documents. 3 Edit Distance要求:Mandatory.实验目的: Ma

24、ny word processors and keyword search engines have a spelling correction feature. If you type in a misspelled word x, the word processor or search engine can suggest a correction y. The correction y should be a word that is close to x. One way to measure the similarity in spelling between two text s

25、trings is by “edit distance”. The notion of edit distance is useful in other fields as well. For example, biologists use edit distance to characterize the similarity of DNA or protein sequences. 实验内容及要求:The edit distance d(x, y) of two strings of text, x1.m and y1.n, is defined to be the minimum pos

26、sible cost of a sequence of “transformation operations”(defined below) that transforms string x1.m into string y1.n. To define the effect of the transformation operations, we use an auxiliary string z1.s that holds the intermediate results. At the beginning of the transformation sequence s = m and z

27、1.s = x1.m (i.e., we start with string x1.m). At the end of the transformation sequence, we should have s = n and z1.s = y1.n(i.e., our goal is to transform into string y1.n). Throughout the transformation, we maintain the current length s of string z, as well as a cursor position i, i.e., an index

28、into string z. The invariant 1 i s +1 holds at all times during the transformation. (Notice that the cursor can move one space beyond the end of the string z in order to allow insertion at the end of the string.)Each transformation operation may alter the string z, the size s, and the cursor positio

29、n i. Each transformation operation also has an associated cost. The cost of a sequence of transformation operations is the sum of the costs of the individual operations on the sequence. The goal of the edit-distance problem is to find a sequence of transformation operation of minimum cost that trans

30、forms x1.m into y1.n.There are five transformation operations:Operation Cost Effectleft 0 If i = 1 then do nothing. Otherwise, set i i-1right 0 If i = s +1 then do nothing. Otherwise, set i i-1.replace 4 If i = s +1 then do nothing. Otherwise, replace the character under the cursor by another charac

31、ter c by setting zi c, and then incrementing i.delete 2 If i = s +1 then do nothing. Otherwise, delete the character c under the cursor by setting zi.s zi+1.s+1 and decrementing s. The cursor position i does not change. insert 3 Insert the character c into string z by incrementing s, setting zi +1.s

32、 zi.s-1, setting zi c, and then incrementing index i.As an example, one way to transform the source string algorithm to the target string analysis is to use the sequence of operations shown in Table 1, where the position of the underlined character represents the cursor position i. Many other sequences of transformation operations also transform algorithm to analysis the solution in Table 1 is not unique and some other solutions

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1