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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

数据结构与算法分析C++版答案.docx

1、数据结构与算法分析C+版答案Data Structures and Algorithm 习题答案Preface ii 1 Data Structures and Algorithms 1 2 Mathematical Preliminaries 5 3 Algorithm Analysis 17 4 Lists, Stacks, and Queues 23 5 Binary Trees 32 6 General Trees 40 7 Internal Sorting 46 8 File Processing and External Sorting 54 9Searching 58 10 In

2、dexing 64 11 Graphs 69 12 Lists and Arrays Revisited 76 13 Advanced Tree Structures 82 i ii Contents 14 Analysis Techniques 88 15 Limits to Computation 94 Preface Contained herein are the solutions to all exercises from the textbook A Practical Introduction to Data Structures and Algorithm Analysis,

3、 2nd edition. For most of the problems requiring an algorithm I have given actual code. In a few cases I have presented pseudocode. Please be aware that the code presented in this manual has not actually been compiled and tested. While I believe the algorithms to be essentially correct, there may be

4、 errors in syntax as well as semantics. Most importantly, these solutions provide a guide to the instructor as to the intended answer, rather than usable programs. 1 Data Structures and Algorithms Instructors note: Unlike the other chapters, many of the questions in this chapter are not really suita

5、ble for graded work. The questions are mainly intended to get students thinking about data structures issues. 1.1 This question does not have a specific right answer, provided the student keeps to the spirit of the question. Students may have trouble with the concept of “operations.” 1.2 This exerci

6、se asks the student to expand on their concept of an integer representation. A good answer is described by Project 4.5, where a singly-linked list is suggested. The most straightforward implementation stores each digit in its own list node, with digits stored in reverse order. Addition and multiplic

7、ation are implemented by what amounts to grade-school arithmetic. For addition, simply march down in parallel through the two lists representing the operands, at each digit appending to a new list the appropriate partial sum and bringing forward a carry bit as necessary. For multiplication, combine

8、the addition function with a new function that multiplies a single digit by an integer. Exponentiation can be done either by repeated multiplication (not really practical) or by the traditional (log n)-time algorithm based on the binary representation of the exponent. Discovering this faster algorit

9、hm will be beyond the reach of most students, so should not be required. 1.3 A sample ADT for character strings might look as follows (with the normal interpretation of the function names assumed). Chap. 1 Data Structures and Algorithms / Concatenate two strings String strcat(String s1, String s2);

10、/ Return the length of a string int length(String s1); / Extract a substring, starting at start, / and of length length String extract(String s1, int start, int length); / Get the first character char first(String s1); / Compare two strings: the normal C+ strcmp function. Some / convention should be

11、 indicated for how to interpret the / return value. In C+, this is 1 for s1s2. int strcmp(String s1, String s2) / Copy a string int strcpy(String source, String destination) 1.4 The answer to this question is provided by the ADT for lists given in Chapter 4. 1.5 Ones compliment stores the binary rep

12、resentation of positive numbers, and stores the binary representation of a negative number with the bits inverted. Twos compliment is the same, except that a negative number has its bits inverted and then one is added (for reasons of efficiency in hardware implementation). This representation is the

13、 physical implementation of an ADT defined by the normal arithmetic operations, declarations, and other support given by the programming language for integers. 1.6 An ADT for two-dimensional arrays might look as follows. Matrix add(Matrix M1, Matrix M2); Matrix multiply(Matrix M1, Matrix M2); Matrix

14、 transpose(Matrix M1); void setvalue(Matrix M1, int row, int col, int val); int getvalue(Matrix M1, int row, int col); List getrow(Matrix M1, int row); One implementation for the sparse matrix is described in Section 12.3 Another implementation is a hash table whose search key is a concatenation of

15、the matrix coordinates. 1.7 Every problem certainly does not have an algorithm. As discussed in Chapter 15, there are a number of reasons why this might be the case. Some problems dont have a sufficiently clear definition. Some problems, such as the halting problem, are non-computable. For some problems, such as one typically studied by artificial intelligence researchers, we simply dont know a solution. 1.8 We must assume that by “algorithm” we mean something composed of steps are

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

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