数据结构基础(C语言版)习题英文版答案.docx
《数据结构基础(C语言版)习题英文版答案.docx》由会员分享,可在线阅读,更多相关《数据结构基础(C语言版)习题英文版答案.docx(160页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、本人答案整理自http: www.cise.ufl.edu/sahni/fdsc2ed/没有进行校对,仅为方便自L断网或网络不好时使用.如有纸漏,望请见谅.因见多有人寻此资源不果,遂分享之,以报多年来众驴友分享于我之万一.本答案为 英文版数据结构基础(C语言版)即FUNDAMENTALS OF DATA STRUCTURES IN C部分习题答案.答案所有文字描述均为英文.且仅有大部分习题答案.少数习题答案网站没有给出,因而我也 没有办法.本人排版水平不佳,全部复制粘贴网站内容,几乎未经过任何排版,大家就将就看下吧.目录CHAPTER 1 2CHAPTER 2 24CHAPTER 3 44CH
2、APTER 4 63CHAPTER 5 79CHAPTER 6 96CHAPTER 7 125CHAPTER 8 139CHAPTER 9 140CHAPTER 10 142CHAPTER 11 147CHAPTER 12 170CHAPTER 1Chapter 1, Pages 16-17Problem l.a This statement is a poorly phrased version of Fermats last theorem. We know that we can find n 2 for which ,the equation holds. Fermat scribbl
3、ed a note on a text margin indicating that he had found the solution for n = 2. Unfortunately, the proof died with him. Because the statement is phrased as a question, rather than a clearly defined algorithm, it lacks definiteness.Problem l.b This statement violates not only the rules of mathematics
4、, but the criterion of effectiveness. We can compute only those things that are feasible, and division by zero is mathematically undefinedPage 17, Exercise 3include include include #defineTRUE 1#define FALSE 0#define MAX_STRING 100 void truth_table(int);int main()int n;printf(n:(=0):);scanf(“d”,&n);
5、while (n =0): scanf(d,&n);)truth_table(n);void truth_table(int n)/* generate a truth_table by transforming # of permutations into binary */int ij, div, rem;char stringMAX_STRING;for (i=0; i O;j-)/number of bits needed for each row*/rem = div%2;div = div/2;if (!rem) strcat(string/FALSE );else strcat(
6、string/ TRUE );printf(%sn,/ string);Page 17, Exercise 4 include int min(intz int);#defineTRUE 1#define FALSE 0int main()(int x,y,z;printf(x:); scanf(%d, &x);printf(y:scanf (,%d, &y);printf(Hz:); scanf(H%d, &z);if(min(x,y) & min(y,z) /*x is smallest */printf(%d , x);if (min(y,z) printf (%d %dnz y,z);
7、else printf(H%d%dn, z, y);else if (min(y,x) & min(y,z) /*y is the smallest */ printf(H%d , y);if (min(xzz) printf (%d %dn/ x,z);else printf(%d%dn/ z,x);) elseprintf(H%d %d %dnz z, y, x);int min(int 3f int b) if (a b) return TRUE;return FALSE;Page 17, Exercise 7#include double iterFact(int); double r
8、ecurFact(int);int main()int n;printf(n:(=0):); scanf(%d/ &n); while (n =0): scanf(”cT, &n);printf(%d factorial is %f.n,nz iterFact(n); printf(%d factorial is%f.n,nz recurFact(n);)double recurFact(int n)/*recursive version +/if (n=0) 11 (n=l) return 1.0; return n*recurFact(n-l);)double iterFact(int n
9、)/* find the factorial, return as a double to keep it from overflowing */int i;double answer;if (n = 0) 11 (n = 1) return 1.0;answer = 1.0;for (i = n; i 1; i-) answer *= i;return answer;Page 17, Exercise 8include int iterFib(int);int recurFib(int);int main()int n;printf(n:(=0):);scanf(”d”, &n);while
10、 (n =0):scanf(d,&n);)printf(%d Fibonacci is %d.n/ nz iterFib(n);printf(%d Fibonacci is %d.n, n, recurFib(n);int recurFib(int n)/*recursive version */if (n=0) 11 (n=l) return 1;return recurFib(n-l) + recurFib(n-2);int iterFib(int n)/* find the factorial, return as a doubleto keep it from overflowing
11、*/int i;int fib, fibl, fib2;if (n = 0) 11 (n = 1) return 1;fibl = fib2 = 1;for (i = 2; i =n; i+) fib = fibl+fib2;fib2 = fibl;fibl = fib;return fib;Page 17, Exercise 9include double recurBinom(int, int);double iterBinomfint, int);double recurFact(int n);int main()int nzm;printf(n:(=0):);scanf(%d,&n);
12、while (n =0):);scanf(%d, &n);printf(m:(=0):);scanf(“d”, &m);while (m =0):);scanf(d“,&m);)printf(n: %d m: %d Recursive Binomial coefficient is %f.n, n, m, recurBinom(n/m); printf(n: %d m: %d Iterative Binomial coefficient is %f.nz n, m, iterBinom(nzm);double iterBinom(int n, int m)/* defined as n!/(m
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据结构 基础 语言版 习题 英文 答案
限制150内