浙江大学离散数学2015期末考试题(英文班)

合集下载

离散数学期末考试题及详细答案

离散数学期末考试题及详细答案

离散数学期末考试题及详细答案一、选择题(每题5分,共20分)1. 在离散数学中,下列哪个概念用来描述元素与集合之间的关系?A. 并集B. 交集C. 子集D. 元素答案:D2. 布尔代数中,下列哪个运算符表示逻辑“与”?A. ∨B. ∧C. ¬D. →答案:B3. 下列哪个命题的否定是正确的?A. 如果今天是周一,则明天是周二。

B. 如果今天是周一,则明天不是周二。

答案:B4. 在图论中,一个图的顶点数为n,边数为m,下列哪个条件可以保证该图是连通的?A. m > nB. m ≥ nC. m = nD. m > n-1答案:D二、填空题(每题5分,共20分)1. 在集合论中,一个集合的幂集包含该集合的所有______。

答案:子集2. 如果一个函数f: A → B是单射的,那么对于任意的a1, a2 ∈ A,如果a1 ≠ a2,则f(a1) ≠ f(a2)。

这种性质称为函数的______。

答案:单射性3. 在图论中,一个图的直径是指图中任意两个顶点之间的最短路径的最大值。

如果一个图的直径为1,则该图被称为______。

答案:完全图4. 一个布尔表达式可以表示为一系列逻辑运算符和变量的组合。

布尔表达式(A ∧ B) ∨ (¬ A ∧ C)的真值表中,当A为真,B为假,C为真时,整个表达式的值为______。

答案:真三、简答题(每题10分,共30分)1. 请简述什么是图的哈密顿回路,并给出一个例子。

答案:哈密顿回路是图中的一个回路,它恰好访问每个顶点一次。

例如,在一个完全图中,任意一个顶点出发,依次访问其他顶点,最后回到出发点的路径就是一个哈密顿回路。

2. 请解释什么是二元关系,并给出一个二元关系的例子。

答案:二元关系是定义在两个集合上的一个关系,它关联了第一个集合中的元素和第二个集合中的元素。

例如,小于关系是实数集合上的一个二元关系,它关联了每一对实数,如果第一个数小于第二个数。

离散数学期末考试题附答案和含解析1

离散数学期末考试题附答案和含解析1

..一、填空2.A ,B ,C 表示三个会合,文图中暗影部分的会合表达式为 (B⊕C)-AA C4.公式(PR)(SR)P的主合取范式为(PSR) ( PS R)。

5.若解说I 的论域D 仅包括一个元素,则 xP(x) xP(x) 在I 下真值为 1 。

6.设A={1,2,3,4},A 上关系图以下,则 R^2={(1,1),(1,3),(2,2),(2,4)}。

//备注: 0 1 0 01 0 1 0 0 1 0 1R 1 0 1 0 R 20 0 0 1 0 0 0 00 0 0 00 0 0 07.设A={a ,b ,c ,d},其上偏序关系R 的哈斯图以下,则R={(a,b),(a,c),(a,d),(b,d),(c,d)}U{(a,a),(b,b)(c,c)(d,d)}。

备注:偏序知足自反性,反对称性,传达性8.图 的补图为 。

//补图:给定一个图G,又G 中全部结点和全部能使 G 成为完整图的增添边构成的图,成为补图. 自补图:一个图假如同构于它的补图,则是自补图 9.设A={a ,b ,c ,d},A 上二元运算以下:* a b c da abcd b b c d a ccdabd d a b c那么代数系统<A ,*>的幺元是 a ,有逆元的元素为a,b,c,d,它们的逆元分别为a,b,c,d 。

//备注:二元运算为 x*y=max{x,y},x,y A 。

10.以下图所示的偏序集中,是格的为 c。

//(注:什么是格?即随意两个元素有最小上界 和最大 下界的偏序)二、选择题 1、以下是真命题的有( C 、D )A .{a} {{a}};B .{{}} { ,{}};C .{{}, }; D .{} {{ }}。

2、以下会合中相等的有( B 、C )A .{4,3} ;B .{ ,3,4};C .{4, ,3,3};D .{3,4}。

;....3、设A={1,2,3},则A 上的二元关系有( C )个。

离散数学期末考试试题及答案

离散数学期末考试试题及答案

离散数学期末考试试题及答案离散数学期末考试试题及答案离散数学是研究离散量的结构及其相互关系的数学学科,是现代数学的一个重要分支。

下面是小编整理的离散数学期末考试试题及答案,欢迎阅读参考!一、【单项选择题】(本大题共15小题,每小题3分,共45分)在每小题列出的四个选项中只有一个选项是符合题目要求的,请将正确选项前的字母填在答题卷相应题号处。

1、在由3个元素组成的集合上,可以有 ( ) 种不同的'关系。

[A] 3 [B] 8 [C]9 [D]272、设A1,2,3,5,8,B1,2,5,7,则AB( )。

[A] 3,8 [B]3 [C]8 [D]3,83、若X是Y的子集,则一定有( )。

[A]X不属于Y [B]X∈Y[C]X真包含于Y [D]X∩Y=X4、下列关系中是等价关系的是( )。

[A]不等关系 [B]空关系[C]全关系 [D]偏序关系5、对于一个从集合A到集合B的映射,下列表述中错误的是( )。

[A]对A的每个元素都要有象 [B] 对A的每个元素都只有一个象[C]对B的每个元素都有原象 [D] 对B的元素可以有不止一个原象6、设p:小李努力学习,q:小李取得好成绩,命题“除非小李努力学习,否则他不能取得好成绩”的符号化形式为( )。

[A]p→q [B]q→p [C]┐q→┐p [D]┐p→q7、设A={a,b,c},则A到A的双射共有( )。

[A]3个 [B]6个 [C]8个 [D]9个8、一个连通G具有以下何种条件时,能一笔画出:即从某结点出发,经过中每边仅一次回到该结点( )。

[A] G没有奇数度结点 [B] G有1个奇数度结点[C] G有2个奇数度结点 [D] G没有或有2个奇数度结点9、设〈G,*〉是群,且|G|>1,则下列命题不成立的是( )。

[A] G中有幺元 [B] G中么元是唯一的[C] G中任一元素有逆元 [D] G中除了幺元外无其他幂等元10、令p:今天下雪了,q:路滑,则命题“虽然今天下雪了,但是路不滑”可符号化为( )[A] p→┐q [B] p∨┐q[C] p∧q [D] p∧┐q11、设G=的结点集为V={v1,v2,v3},边集为E={,}.则G的割(点)集是( )。

离散数学答案英文版

离散数学答案英文版

离散数学答案英⽂版P.161.14.f) If I did not buy a lottery ticket this week, then I did not win the million dollar jackpot on Friday.g) I did not buy a lottery ticket this week, and I did not win the million dollar jackpot on Friday.h ) Either I did not buy a lottery ticket this week, or else I did buy one and won the million dollar jackpot on Friday.10.a) r ∧┐q b) p ∧ q∧ r c)r → pd) p ∧┐q ∧ r e) (p ∧q) → r f) r? ( q ∨ p)20.a) If I am to remember to send you the address, then you will have to send me ane-mail message.(This has been slightly reworded so that the tenses make more sense.)b) If you were born in the United States, then you are a citizen of this country.c) If you keep your textbook, then it will be a useful reference in your future courses.(The word "then" is understood in English, even if omitted.)d) If their goaltender plays well, then the Red Wings will win the Stanley Cup.e) If you get the job, then you had the best credentials.f) If there is a storm, then the beach erodes.g) If you log on to the server, then you have a valid password.h) If you don’t begin your climb too late, then you will reach the summit.33.c)P.261.28.a) Kwame will not take a job in industry and he will not go to graduate school.b) Yoshiko doesn’t know Java or she doesn’t know calculus.c) James is not young or he is not strong.d) Rita will not move to Oregon and she will not move to Washington.10.a)c)12.a) Assume the hypothesis is true. Then p is false. Since p∨q is true, we conclude that q must be true.Here is a more "algebraic" solution:[┐p∧(p ∨q)]→q <=> ┐[┐p∧(p ∨q)]∨q <=> ┐┐p∨┐(p∨q)∨q <=> p∨┐(p∨q)∨q <=> (p ∨q)∨┐(p∨q) <=> Tc) Assume the hypothesis is true. Then p is true, and since the second part of the hypothesis is ture, we conclude that q is also true, as desired.51.((p ↓ p) ↓ q )↓((p ↓ p) ↓ q )7.The graph is planar.20.The graph is not homeomorphic to K3,3, since by rerouting the edge between a and h we see that it is planar.22.Replace each vertex of degree two and its incident edges by a single edge. Then the result is K3,3 : the parts are {a,e,i} and {c,g,k}. Therefore this graph is homeomorphic to K3,3.23.The graph is planar.25. The graph is not planar.9.83. 3F E8. 310.417. time slot 1: Math 115, Math 185; time slot 2: Math 116, CS 473;time slot 3: Math 195, CS 101; time slot 4: CS 102time slot 5: CS 273P.461.33. a) true b) false c) false d) false5. a) There is a student who spends more than 5 hours every weekday in class.b) Every student spends more than 5 hours every weekday in class.c) There is a student who does not spend more than 5 hours every weekday in class.d) No student spends more than 5 hours every weekday in class.9. a) x(P(x)∧Q(x)) b) x(P(x)∧﹁Q(x))c) x(P(x)∨Q(x)) d) x﹁(P(x)∨Q(x))16. a) true b) false c) true d) false24. Let C(x) be the propositional function “x is in your class.”a)x P(x) and x(C(x)→P(x)), where P(x) is “x has a cellular phone.”b) x F(x) and x(C(x)∧F(x)), where F(x) is “x has seen a foreign movie.”c)x﹁S(x) and x(C(x)∧﹁S(x)), where S(x) is “x can swim.”d)x E(x) and x(C(x)→E(x)), where E(x) is “x can solve quad ratic equations.”e)x﹁R(x) and x(C(x)∧﹁R(x)), where R(x) is “x wants to be rich.”62.a) x (P(x)→﹁S(x)) b)x(R(x)→S(x))c) x (Q(x)→P(x))d)x(Q(x)→﹁R(x))e) Yes. If x is one of my poultry, then he is a duck (by part(c)), hence not willing to waltz (part (a)). Since officers are always willing to waltz (part (b)), x is not an officer.1.412.d)x┐C(x, Bob)h)x y (I(x) ∧((x≠y) →┐ I(y)))k)x y( I(x) ∧┐C(x, y))n)x y z ((x≠y) ∧┐ (C(x, z) ∧ C(y, z)))14.a) x H(x), where H(x) is “x can speak Hindi”and the universe of the discourse consists of all students in this class.b) x y P(x, y), where P(x, y) is “x plays y.” and the universe of the discourse for x consists of all students in this class, and the universe of the discourse for y consists of all sports.c) x A(x) ∧┐H(x) , where A(x) is “x has visited Alaska.” , H(x) is “x has visited Hawaii” and the universe of the discourse for x consists of all students in this class.d) x y L(x, y), where L(x, y) is “x has learned programming language y” and the universe of the discourse for x consists of all students in this class, and the universe of the discourse for y consists of all programming languages.e) x z y (Q(y,z) →P(x, y)), where P(x, y) is“x has taken course y.”, Q(y, z) is “course y is offered by department z.”, and theuniverse of the discourse for x consists of all students in this class, the universe of the discourse for y consists of all courses in this school, and the universe of the discourse for z consists of all departments in this school.f)x y z ( (x≠y) ∧P(x, y)∧ ((x≠y≠z) →┐P(x, z))), where P(x, y) is “x and y grew up in the same town.” and the universe of the discourse for x, y, z consists of all students in this class.g) x y z C(x, y) ∧G(y, z), where C(x, y) is “x has chatted with y”, G(y, z) is “y is in chat group z”, the universe of the discourse for x, y consists of all students in this class, and the universe of the discourse for z consists of all chat group in this class. a) There is an additive identity for the real numbers.d) The product of two nonzero numbers is nonzero for the real numbers.38.b) There are no students in this class who have never seen a computer.d) There are no students in this class who have taken been in at least one room of every building on campus.1.5(1)(┐r∧(q→p))→(p→(q∨r)) <=> ┐(┐r∧(┐q∨p))∨(┐p∨(q∨r)) <=>(q∧┐p)∨(┐p∨q∨r)<=> (┐p∨q∨r∨q)∧(┐p∨q∨r∨┐p) <=> (┐p∨q∨r) <=> ∏3 <=> ∑0,1,2,4,5,6,7 (2) P.726. Let r be the proposition "It rains", let f be the proposition "It is foggy", let s be the proposition "The sailing race will be held", let l be the proposition "The lifesaving demonstration will go on", and let t be the proposition "The trophy will be awarded". We are given premises (┐r∨┐f)→(s∧l), s→t, and ┐t. We want to conclude r. We set up the proof in two columns, with reasons. Note that it is valid to replace subexpressions by other expressions logically equivalent to them.Step Reason1. ┐t Hypothesis2. s→t Hypothesis3. ┐s Modus tollens using Steps 1 and 24. (┐r∨┐f)→(s∧l) Hypothesis5. (┐(s∧l))→┐(┐r∨┐f) Contrapositive of step 46. (┐s∨┐l)→(r∧f) De Morgan's law and double negative7. ┐s∨┐l Addition, using Step 38. r∧f Modus ponens using Step 6 and 79. r Simplification using Step 8First, using the conclusion of Exercise 11, we should show that the argument form with premises (p ∧t) → (r ∨s), q→ (u ∧t), u→p, ┐s, q, and conclusion r is valid. Then, we use rules of inference from Table 1.Step Reason1. q Premise2. q→ (u ∧t)P remise3. u ∧t Modus ponens using Steps 1 and 24. u Simplification using Step 35. u→p Premise6. p Modus ponens using Steps 3 and 47. t Simplification using Step 38. p ∧t Conjunction using Steps 6 and 79. (p ∧t) → (r ∨s) Premise10. r ∨s Modus ponens using Steps 8 and 911. ┐s Premise12. r Disjunctive syllogism using Steps 10 and 11 14.b)Let R(x) be “x is one of the five roommates,” D(x) be “x has taken a course in discrete mathematics,” and A(x) be “x can take a course in algorithms.” The premises are x (R(x) → D(x)), x (D(x) → A(x)) and R(Melissa). Using the first premise and Universal Instantiation, R(Melissa) → D(Melissa) follows. Using the third premise and Modus Ponens, D(Melissa) follows. Using the second premise and Universal Instantiation, A(Melissa) follows. So do the other roommates.d) Let C(x) be “x is in the class,”F(x) be “x has been to France,” and L(x) be “x has visited Louvre.” The premises are x(C(x)∧F(x)) and x (F(x) → L(x)). From the first premise and Existential Instantiation imply that C(y) ∧F(y) for a particularperson y. Using Simplification, F(y) follows. Using the second premise and Universal Instantiation F(y) → L(y) follows. Using Modus Ponens, L(y) follows. Using Existential Generalization, x(C(x) ∧L(x)) follows.24. The errors occur in steps (3), (5) and (7).For steps (3) and (5), we cannot assume, as is being done here, that the c that makes P(x) true is the same as the c that makes Q(x) true at the same time. For step (7), it is not a conjunction and there is no such disjunction rule.29.Step Reason1. x ┐P(x) Premise2. ┐P(c) Existential instantiation from (1)3. x (P(x) ∨Q(x)) Premise4. P(c) ∨Q(c) Universal instantiation from (3)5. Q(c) Disjunctive syllogism from (2) and (4)6. x (┐Q(x) ∨S(x)) Premise7. ┐Q (c) ∨S(c) Universal instantiation from (6)8. S(c) Disjunctive syllogism from (5) and (7)9. x (R(x) →┐S(x)) Premise10. R(c) →┐S(c) Universal instantiation from (9)11. ┐R(c) Modus tollens from (8) and (10)12. x ┐R(x) Existential generalization from (11)P.861.637.Suppose that P1→P4→P2→P5→P3→P1. To prove that one of these propositions implies any of the others, just use hypothetical syllogism repeatedly.P.1031.713.a) This statement asserts the existence of x with a certain property. If we let y=x, then we see that P(x) is true. If y is anythingother than x, then P(x) is not true. Thus, x is the unique element that makes P true.b) The first clause here says that there is an element that makes P true. The second clause says that whenever two elements both make P true, they are in fact the same element. Together these say that P is satisfied by exactly one element.c) This statement asserts the existence of an x that makes P true and has the further property that whenever we find an element that makes P true, that element is x. In other words, x is the unique element that makes P true.P.1202.19.T T F T T F16. Since the empty set is a subset of every set, we just need to take a set B that contains Φ as an element. Thus we can letA = Φ andB = {Φ} as the simplest example.20 .The union of the sets in the power set of a set X must be exactly X. In other words, we can recover X from its power set, uniquely. Therefore the answer is yes.22.a) The power set of every set includes at least the empty set, so the power set cannot be empty. Thus Φ is not the power set of any set.b) This is the power set of {a}c) This set has three elements. Since 3 is not a power of 2, this set cannot be the power set of any set.d) This is the power set of {a,b}.28.a) {(a,x,0), (a,x,1), (a,y,0), (a,y,1), (b,x,0), (b,x,1), (b,y,0), (b,y,1), (c,x,0), (c,x,1), (c,y,0), (c,y,1)}c) {(0,a,x), (0,a,y), (0,b,x), (0,b,y), (0,c,x), (0,c,y), (1,a,x), (1,a,y), (1,b,x), (1,b,y), (1,c,x), (1,c,y)}P.1302.214. Since A = (A - B)∪(A∩B), we conclude that A = {1,5,7,8}∪{3,6,9} ={1,3,5,6,7,8,9}. Similarly B = (B - A)∪(A ∩ B) = {2,10}∪{3,6,9} = {2,3,6,9,10}.24. First suppose x is in the left-hand side. Then x must be in A but in neither B nor C. Thus x∈A - C, but x B - C, so x is in the right-hand side. Next suppose that x is in the right-hand side. Thus x must be in A - C and not in B - C. The first of these implies that x∈A and x C. But now it must also be the case that x B, since otherwise we would have x∈B - C. Thus we have shown that x is in A but in neither B nor C, which implies that x is in the left-hand side.40. This is an identity; each side consists of those things that are in an odd number of the sets A,B,and C.P147.2.335a) This really has two parts. First suppose that b is in f(S∪T). Thus b=f(a) for somea∈S∪T. Either a ∈S, in which case b∈f(S), or a∈T, in which case b∈f(T). Thus in either case b∈ f(S) ∪f(T). This shows that f(S∪T) ?f(S) ∪f(T), Conversely, suppose b∈f(S) ∪f(T). Then either b∈f(S) or b∈f(T). This means either that b=f(a) for somea∈S or that b=f(a) for some a ∈T. In either case, b=f(a) for some a∈S∪T, so b∈f(S∪T). This shows that f(S) ∪f(T) ?f(S∪T), and our proof is complete. b)Suppose b∈f(S∩T). Then b=f(a) for some a∈S∩T. This implies that a∈S anda∈T , so we have b∈f(S) and b∈f(T). Therefore b∈f(S)∩f(T), as desired.52In some sense this question is its own answer—the number of integers between a and b, inclusive, is the number of integers between a and b, inclusive. Presumably we seek an express involving a, b, and the floor and/or ceiling function to answer this question. If we round a up and round b down to integers, then we will be looking at the smallest and largest integers just inside the range of the integers we want to count, respectively. These values are of course ??a and ??b, respectively. Then the answer isb-+1 (just think of counting all the integers between these two values, aincluding both ends—if a row of fenceposts one foot apart extends for k feet, then there are k +1 fenceposts). Note that this even works when, for example, a=0.3 and b=0.7 .P1622.434.a) This is countable. The integers in the set are ±1,±2,±4,±5,±7,andso on. We can listthese numbers in the order 1, -1 , 2, -2, 4, -4,…, thereby establishing the desired correspondence. In other words, the correspondence is given by 1?1,2?-1,3?2,4?-2,5?4,and so on.b) This is similar to part(a);we can simply list the elements of the set in order ofincreasing absolute value, listing each positive term before its correspondingnegative:5,-5,10,-10,15,-15,20,-20,30,-30,40,-40,45,-45,50,-50,……c) This is countable but a little tricky. We can arrange the numbers in a 2-dimensionaltable as follows:1..1 0.11 0.111 0.1111 0.11111 ……1.1 1 1.1 1.11 1.111 1.1111 ……1.1111 11.1 11.11 11.111 11.1111 ……1111.111 111.1 111.11 111.111 111.1111 ……………………………………d) This set is not countable. We can prove it by the same diagonalization argument aswas used to prove that the set of all reals is uncountable in Example 21.All we need to do is choose d i=1 when d ii=9 and choose d i=9 when d ii=1 or d ii is blank(if the decimal expansion is finite)46.We know from Example 21 that the set of real numbers between 0 and 1 is uncountable. Let us associate to each real number in this range(including 0 but excluding 1) a function from the set of positive integers to the set {0,1,2,3,4,5,6,7,8,9} as follows: If x is a real number whose decimal representation is 0.d1d2d3…(with ambiguity resolved by forbidding the decimal to end with an infinite string of9's),then we associate to x the function whose rule is given by f(n)=d n. clearly this is a one-to-one function from the set of real numbers between 0 and 1 and a subset of the set of all functions from the set of positive integers the set{0,1,2,3,4,5,6,7,8,9}.Two different real numbers must have different decimal representations, so the corresponding functions are different.(A few functions are left out, because of forbidding representations such as 0.239999…)Since the set of real numbers between 0 and 1 is uncountable, the subset of functions we have associated with them must be uncountable. But the set of all such functions has at least this cardinality, so it, too, must be uncountable.P1913.21. The choices of C and k are not unique.a) Yes C = 1, k = 10 b) Yes C = 4, k = 7 c) Nod) Yes C = 5, k = 1 e) Yes C = 1, k = 0 f) Yes C = 1, k = 29. x2+4x+17 ≤ 3x3 for all x>17, so x2+4x+17 is O(x3), with witnesses C = 3, k=17. However, if x3 were O(x2+4x+17), thenx3≤C(x2+4x+17) ≤ 3Cx2for some C, for all sufficiently large x, which implies that x≤ 3C, for all sufficiently large x, which is impossible.P2093.419.a) no b) no c) yes d) no31.a) GR QRW SDVV JRb) QB ABG CNFF TBc) QX UXM AHJJ ZXP2183.513.a) Yes b) No c) Yes d) Yes17a) 2 b) 4 c) 12P2804.122.A little computation convinces us that the answer is that n2 ≤ n! for n= 0, 1, and all n≥ 4. (clearly the inequality doesn’t hold for n=2 or n=3) We will prove by mathematical induction that the inequality holds for all n≥ 4. The base case is clear, since 16 ≤24. Now suppose that n2 ≤ n! for a given n≥ 4. We m ust show that (n+1)2≤ (n+1)!. Expanding the left-hand side, applying the inductive hypothesis, and then invoking some valid bounds shows this:n2 + 2n+ 1 ≤ n! + 2n + 1≤ n! + 2n + 1 = n! + 3n≤ n! + n·n≤ n! + n·n!≤ (n+1)n! = (n+1)!P2934.231.Assume that the well-ordering property holds. Suppose that P(1) is true and that the conditional statement [P(1)∧P(2)∧···∧P(n)] →P(n+1) is true for every positive integer n. Let S be the set of positive integers n for which P(n) is false. We will show S=?. Assume that S≠?, then by the well-ordering property there is a least integer m in S. We know that m cannot be 1 because P(1) is true. Because n=m is the least integer such that P(n) is false, P(1), P(2),…,P(m-1) are true, and m-1 ≥1. Because [P(1)∧P(2) ∧···∧P(m-1)] →P(m) is true, it follows that P(m) must also be true, which is a contradiction. Hence, S= ?. P3084.310.The base case is that S m(0)=m. The recursive part is that S m(n+1) is the successor of S m(n)(i.e., S m(n)+1)12.The base case n=1 is clear, since f12=f1f2=1. Assume the inductive hypothesis. Thenf12+f22+…+f n2+f n+12 = f n+12+f n f n+1= f n+1(f n+1+f n)= f n+1f n+2, as desired.31.If x is a set or variable representing set, then x is well-formed formula. if x and y are all well-formed formulas, then x, (x∪y), (x∩y) and (x-y) are all well-formed formulas.50.Let P(n) be “A(1, n) = 2n .”BASIC STEP: P(1) is true, because P(1) = A(1, 1) = 2 = 21.INDCUTIVE STEP: Assume that P(m) is true, that is A(1, m) = 2m and m≥1. Then P(m+1) = A(1, m+1) = A(0, A(1, m))= A(0, 2m)=2·2m=2m+1.So A(1, n) = 2n whenever n≥159.b) Not well defined. F(2) is not defined since F(0) isn’t.Also, F(2) is ambiguous.d) Not well defined. The definition is ambiguous about n=1.P3445.13.a) 104b) 10512.We use the sum rule, adding the number of bit strings of each length up to 6. If we include the empty string, then we get 20 + 21 + 22 + 23 + 24 + 25 + 26= 27–1=12720.a) Every seventh number is divisible by 7. Therefore there are 999 / 7=142such numbers. Note that we use the floor function, because the k th multiple of 7 does not occur until the number 7k has been reached.b) For solving this part and the next four parts, we need to use the principle of inclusion-exclusion. Just as in part(a), there are 999/11=90 numbers in our range divisible by 11, and there are 999/77=12 numbers in our range divisible by both 7 and 11 (the multiples of 77 are the numbers we seek). If we take these 12 numbers are away from the 142 numbers divisible by 7, we see that there are 130 numbers in our range divisible by 7 but not by 11.c) as explained in part(b), the answer is 12.d) By the principle of inclusion-exclusion, the answer, using the data from part (b), is 142+90-12=220.e) If we subtract from the answer to part(d) the number of numbers divisible by neither of them; so the answer is 220-12=208.f) If we subtract the answer to part(d) from the total number of positive integers less than 1000, we will have the number of numbers divisible by exactly one of them; so the answer is 999-220=779.g) If we assume that numbers are written without leading 0s, then we should break the problem down into three cases-one-digit numbers, two-digit numbers. Clearly there are 9 one-digit numbers, and each of them has distinct digits. There are 90 two-digit numbers (10 through 99), and all but 9 of them have distinct digits. An alternativeway to compute this is to note that the first digit must be 1 through 9 (9 choices) and the second digit must be something different from the first digit (9 choices out of the 10 possible digits), so by the product rule, we get 9*9=81 choices in all. This approach also tells us that there are 9*9*8=648 three-digit numbers with distinct digits (again, work from left to right-in the ones place, one 8 digits are left to choose from). 80 the final answer is 9+81+648=738.h) It turns out to be easier to count the odd numbers with distinct digits and subtract from our answer to part(g), so let us proceed that way. There are 5 odd one-digit numbers. For two-digit numbers, first choose the one digit (5 choices), then choose the tens digits (8 choices), since neither the ones digit value not 0 is available); therefore there are 40 such two-digit numbers. (Note that this is not exactly half of 81.) For the three-digit numbers, first choose the ones digit (5 choices), then the hundreds digit (8 choices), then the tens digit (8 choices), giving us 320 in all. So there are 5+40+320=365 odd numbers with distinct digits. Thus the final answer is 738-365=373.35.a) 若n=1, 为2;若n=2, 为2; 若n>=3, 为0b) 对于n>1, 为22 n;若n=1, 为1;c) 2(n-1) (注:n可映射到0,1两种可能)44.First we count the number of bit strings of length 10 that contain five consecutive 0’s. We will base the count on where the string of five or more consecutive 0’s starts. If it starts in the first bit, then the first five bits are all 0’s, but there is free choice for the last five bits; therefore there are 25 = 32 such strings. If it starts in the second bit, then the first bit must be a 1, the next five bits are all 0’s, but there is free choice for the last four bits; therefore there are 24 = 16 such strings. If it starts in the third bit, then the second bit must be a 1 but the first bit and the last three bits are arbitrary; therefore there are 24= 16 such strings. Similarly, there are 16 such strings that have the consecutive 0’s starting in each of positions four, five ,and six. This gives us a total of 32+5×16=112 strings that contain five consecutive 0’s. Symmetrically, there are 112 strings that contain five consecutive 1’s. Clearly there are exactly two strings that contain both (0000011111,1111100000). Therefore by the inclusion-exclusion principle, the answer is 2*(112)-2=222.52.We draw the tree, with its root at the top. We show a branch for each of the possibilities 0 and 1, for each bit in order, except that we do not allow three consecutive 0’s. Since there are 13 leaves, the answer is 13.second bitthird bitfourth bitP3535.26.There are only d possible remainders when an integer is divided by d, namely 0, 1, …, d-1. By the pigeonhole principle, if wehave d+1 remainders, then at least two must be the same.10.The midpoint of the segment whose endpoints are (a,b) and (c,d) is ( ( a + c ) / 2, ( b + d ) / 2). We are concerned only with integer values of the original coordinates. Clearly the coordinates of these fractions will be integers as well if and only if a and c have the same parity (both odd or both even) and b and d have the same parity. Thus what matters in this problem is the parities of coordinates. There are four possible pairs of parities: (odd,odd), (odd, even), (even, even) and (even,odd). Since we are given five points, the pigeonhole principle guarantees that at least two of them will have the same pair of parties. The midpoint of the segment joining these two points will therefore have integer coordinates.38.a) T b) Tc) T1 ≤a1< a2 < …< a75≤ 125 , and 26 ≤a1 + 25 < a2 + 25 < …< a75 + 25 ≤ 150.Now either of these 150 numbers are precisely all the number from 1 to 150, or else by the pigeonhole principle we get, as in Exercise 37, a i = a j + 25 for some i and j and we are done. In the former case, however, since each of the number a i + 25 is greater than or equal to 26, the numbers 1, 2, … , 25 must all appear among the a i’s. But since the a i’s are increasing, the only way this can happen is if a1=1, a2 =2 , …, a25=25. Thus there were exactly 25 matches in the first25 hours.d) TWe need a different approach for this part, an approach, incidentally, that works for many numbers besides 30 in this setting. Let a1, a2 , …a75 be as before, and note that 1 ≤a1< a2 < …< a75≤ 125. By the pigeonhole principle two of the numbers among a1, a2 , …a 31 are congruent modulo 30. If they differ by 30, then we have our solution. Otherwise they differ by 60 or more, so a 31 ≥ 61. Similarly, among a 31through a 61 ,either we find a solution, or two numbers must differ by 60 or more; therefore we assume that a 61 ≥ 121. But this means that a 66 ≥ 126, a contradiction.注:38题d 因为30⼤于25,不能⽤解决a,b,c的⽅法解决,所以适⽤⼀种新的⽅法(这种⽅法对前⾯3问同样适⽤的)。

离散数学英文试题A

离散数学英文试题A

《离散数学》课程试题【A】卷阅卷须知:阅卷用红色墨水笔书写,得分用阿拉伯数字写在每小题题号前,用正分表示,不得分则在题号前写0;大题得分登录在对应的分数框内;统一命题的课程应集体阅卷,流水作业;阅卷后要进行复核,发现漏评、漏记或总分统计错误应及时更正;对评定分数或统分记录进行修改时,修改人必须签名。

特别提醒:学生必须遵守课程考核纪律,违规者将受到严肃处理。

PLEASE ANSWER IN CHINESE OR IN ENGLISH!!1. Fill the best answer in the blanks (3 points each,15 points in all)(1) If A, B, and C be sets, then (A–C) – (B–C) ___________ A–B.(2) A relation on a set A that is reflexive, symmetric, and transitive is called an (or a) ___________relation.(3) K n has ___________edges.(4) There are _______ __non-isomorphic rooted trees with four vertices.(5) Assume that P(x, y) means “x+ 2y= xy”, where x and y are integers. Then the truth value of thestatement ∀x∃y P(x, y) is _______ __.2. Choose the corresponding letter of the best answer that best completes the statements oranswers the questions among A, B, C, and D and fill the blanks (3 points each,15 pointsin all).(1) Suppose A = {1, 2, 3}. The following statement ( ) is not true. A .∅ ⊆(A )B .{∅} ⊆ (A )C .{2, 3} A AD .{{2}} ⊆(A )(2) Suppose that R and S are transitive relations on a set A . Then ( ) is transitive. A . S R ⋂ B .S R ⋃ C . S R - D .S R(3) There are ( ) strongly connected components of the following graph G .A. 1B. 2C. 3D. 4(4) There are ( ) nonisomorphic undirected trees with 5 vertices.A. 6B. 5.C. 4D. 3(5) Suppose P (x , y ) is a predicate and the universe for the variables x and y is {1,2,3}. Suppose P (1,3), P (2,1), P (2,2), P (2,3), P (3,1), P (3,2) are true, and P (x , y ) is false otherwise. The following statement ( ) is true.A. ∀y ∃x (P (x , y ) → P (y , x ))B. ¬∃x ∃y (P (x , y ) ∧ ¬P (y , x ))C. ∀x ∀y (x ≠ y → (P (x , y ) ∨ P (y , x ))D. ∀y ∃x (x ≤ y ∧ P (x , y ))3. Write “” for true, and “” for false in the blanks at end of each statement (3 pointseach ,15 points in all).(1) There is a set S such that its power set (S) has 12 elements. ( )(2) An irreflexive and transitive relation on a set A is antisymmetric. ( )(3) The largest value of n for which K n is planar is 6. ( )(4) Every full binary tree with 61 vertices has 31 leaves. ( )(5) Logical expressions ))(x)xB(∧∀are equivalent. ( )xA∀x∀and)(x∧((x)AxB4.For any function f: A B, define a new function g: (A) (B) as follows: for every S A, g(S) = {f(x)|x S}. Prove that g is surjective (or onto) if and only f is surjective(or onto). (10 points)5.Find the transitive closure t(R) of R on {a, b, c, d} and draw the graph of t(R) where R = {(a, a), (b, a), (b,c), (c, a), (c, c), (c, d), (d, a), (d, c)}. (10 points)6. Either give an example or prove that there is none: A graph with 7 vertices that has a Hamilton circuit but no Euler circuit. (10 points)7. Let G be an undirected tree with 3 vertices of degree 3, 1 vertex of degree 2, the other vertices of degree 1.(15 points)(1) How many vertices in G are there?(2) Draw two nonisomorphic undirected trees satisfying the above requirements.8. Show that p→ (q→ r) and p→ (q∧ r) are logically equivalent. (10 points)。

离散数学期末考试试题(配答案)

离散数学期末考试试题(配答案)

离散数学期末考试试题(配答案)1. 谓词公式)()(x xQ x xP ∃→∀的前束范式是___________。

2. 设全集{}{}{},5,2,3,2,1,5,4,3,2,1===B A E 则A ∩B =____;=A _____;=B A Y __ _____3. 设{}{}b a B c b a A ,,,,==;则=-)()(B A ρρ__ __________;=-)()(A B ρρ_____ ______。

二.选择题(每小题2分;共10分)1. 与命题公式)(R Q P →→等价的公式是( )(A )R Q P →∨)( (B )R Q P →∧)( (C ))(R Q P ∧→ (D ))(R Q P ∨→ 2. 设集合{}c b a A ,,=;A 上的二元关系{}><><=b b a a R ,,,不具备关系( )性质 (A ) (A)传递性 (B)反对称性 (C)对称性 (D)自反性 三.计算题(共43分)1. 求命题公式r q p ∨∧的主合取范式与主析取范式。

(6分)2. 设集合{}d c b a A ,,,=上的二元关系R 的关系矩阵为⎪⎪⎪⎪⎪⎭⎫⎝⎛=1000000011010001R M ;求)(),(),(R t R s R r 的关系矩阵;并画出R ;)(),(),(R t R s R r 的关系图。

(10分)5. 试判断),(≤z 是否为格?说明理由。

(5分)(注:什么是格?Z 是整数;格:任两个元素;有最小上界和最大下界的偏序)四.证明题(共37分)1. 用推理规则证明D D A C C B B A ⌝⇒∧⌝⌝⌝∧∨⌝→)(,)(,。

(10分)2. 设R 是实数集;b a b a f R R R f +=→⨯),(,:;ab b a g R R R g =→⨯),(,:。

求证:g f 和都是满射;但不是单射。

(10分)一;1; _ ∃x ∃y¬P(x)∨Q(y)2; {2} {4;5} {1;3;4;5}3; {{c};{a ;c};{b ;c};{a ;b ;c}} Φ_ 二;B D三;解:主合取方式:p ∧q ∨r ⇔(p ∨q ∨r)∧(p ∨¬q ∨r)∧(¬p ∨q ∨r)= ∏0.2.4主析取范式:p ∧q ∨r ⇔(p ∧q ∧r) ∨(p ∧q ∧¬r) ∨(¬p ∧q ∧r) ∨(¬p ∧¬q ∧r) ∨(p ∧¬q ∧r)= ∑1.3.5.6.7 四;1;证明:编号 公式 依据 (1) (¬B∨C )∧¬C 前提 (2) ¬B∨C ;¬C (1) (3) ¬B (2) (4) A →B (3) (5) ¬A (3)(4) (6) ¬(¬A∧D ) 前提 (7) A ∨¬D (6) (8)¬D (5)(6)2;证明:要证f 是满射;即∀y ∈R ;都存在(x1;x2)∈R ×R ;使f (x1;x2)=y ;而f (x1;x2)=x1+x2;可取x1=0;x2=y ;即证得;再证g 是满射;即∀y ∈R ;;都存在(x1;x2)∈R ×R ;使g (x1;x2)=y ;而g (x1;x2)=x1x2;可取x1=1;x2=y ;即证得;最后证f 不是单射;f (x1;x2)=f (x2;x1)取x1≠x2;即证得;同理:g (x1;x2)=g (x2;x1);取x1≠x2;即证得。

最新离散数学2014-2015第一学期期末试卷及参考答案

最新离散数学2014-2015第一学期期末试卷及参考答案

华东交通大学2014—2015学年第一学期考试卷试卷编号: ( A )卷离散数学 课程 课程类别:必修 考试日期: 月 日 开卷(范围:可带含课程内容的手写的不超过A4大小的纸一张)注意事项:1、本试卷共 8 页(其中试题4页),总分 100 分,考试时间 120 分钟。

2、所有答案必须填在答题纸上,写在试卷上无效;3、考试结束后,考生不得将试卷、答题纸和草稿纸带出考场。

一、单项选择题(2分×10=20分)1.下列语句是命题的有[ ]。

A. 122>+y x ;B. 2010年的国庆节是晴天;C. 青年学生多么朝气蓬勃呀!D. 学生不准吸烟!2.若一个代数系统是独异点(含幺半群),则以下选项中一定满足的是[ ]。

A. 封闭性,且有零元;B. 结合律,且有幺元;C. 交换性,且有幺元;D. 结合律,且每个元素有逆元.3.Z是整数集合,下列函数都是Z→Z的映射,则[ ]是单射而非满射函数。

A.ϕ (x) =0B.ϕ (x) =x2C.ϕ (x) =2x D.ϕ (x) =x4. 与命题p ∧ (p∨q)等值的公式是[ ]。

A. p;B. q;C. p∨q;D. p∧q.5. 设M={a,b,c},M上的等价关系R={<a,a>,<b,b>,<c,c>,<b,c>,<c,b>}确定的集合M的划分是[ ]。

A.{{a},{b},{c}}B.{{a,c},{b,c}}C.{{a,c},{b}}D.{{a},{b,c}}6. 设D:全总个体域,F(x):x是花,M(x) :x是人,H(x,y):x喜欢y ,则命题“每个人都喜欢某种花”的逻辑符号化为[ ]。

A. ))xFMy∃y∀;∧x→(y()(()x,(HB. ))yFyHM→∃x→∀;x)(,(((y()xC. ))yFyxH→∃x∧∀;M)(,(((y()xD. ))xyFMy→∀x∧∃.()(,()xH(y(7. 下列图中,不是哈密顿图的为[ ]。

英文离散数学试题及答案

英文离散数学试题及答案

英文离散数学试题及答案一、选择题(每题2分,共20分)1. 在集合论中,空集的符号表示为:A. ∅B. ∅∅C. ØD. ∅(∅)2. 布尔代数中,逻辑与(AND)操作的符号是:A. ∧B. ∨C. ¬D. →3. 如果一个命题P是真命题,那么¬P是:A. 假命题B. 真命题C. 既非真也非假D. 无法确定4. 在图论中,一个图的度是指:A. 顶点的数量B. 边的数量C. 每个顶点连接的边数D. 图中所有顶点的度数之和5. 以下哪个是有限自动机的组成部分:A. 状态B. 初始状态C. 转移函数D. 所有上述选项6. 以下哪个不是关系的性质:A. 反射性B. 对称性C. 传递性D. 唯一性7. 一个命题逻辑公式的真值表通常有多少行:A. 2B. 3C. 与变量的数量相同D. 与命题的数量相同8. 以下哪个是等价关系的属性:A. 传递性B. 非传递性C. 非对称性D. 非自反性9. 一个命题逻辑公式的否定等价于:A. 原公式的真值表中所有真值取反B. 原公式的逻辑或C. 原公式的逻辑与D. 原公式的逻辑异或10. 在组合数学中,排列与组合的区别在于:A. 排列考虑顺序B. 组合不考虑顺序C. 排列不考虑顺序D. 所有上述选项答案:1. A2. A3. A4. C5. D6. D7. C8. A9. A10. A, B二、简答题(每题5分,共30分)1. 简述集合的并集和交集的定义。

2. 解释什么是逻辑蕴涵,并给出一个例子。

3. 描述图的有向性和无向性的区别。

4. 阐述关系数据库中主键和外键的作用。

5. 什么是递归函数,并给出一个简单的例子。

6. 简述命题逻辑和谓词逻辑的区别。

三、计算题(每题10分,共30分)1. 给定集合A = {1, 2, 3}和B = {2, 3, 4},求A∪B和A∩B。

2. 证明以下逻辑等价性:(P ∧ Q) → R ≡ P → (Q → R)。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Department of Information Science and Electronic EngineeringZhejiang UniversityFinal Examination11193011Discrete MathematicsAssoc.Prof.Dr.Thomas HonoldM.Sc.Jingmei AiFall Semester,2014Name:Matric.No.:Question123456Marks ObtainedMaximal Marks151515201520100Time allowed:120minutesInstructions to candidates:•This examination paper contains six(6)questions.•Please answer every question and subquestion,and justify your answers.•For your answers please use the space provided after each question.If this space is insufficient,please continue on the blank sheets provided.•This is a CLOSED BOOK examination,except that you may bring1sheet of A4paper(hand-written only)and a Chinese-English dictionary(paper copy only)to the examination.Question1(15marks)a)Is(p1↔p2)∨p1a tautology?b)Are(p1→p2)→p3and p1→(p2→p3)logically equivalent?c)Fermat’s Last Theorem(FLT)states that the equation x n+y n=z n hasno integer solution with xyz=0and n≥3.Express FLT as a formula ofpredicate calculus with domain Z.Note:You may use the basic operations of ordinary arithmetic,includingpowers‘x n’and the comparison operators’=’,’≤’.No further abbreviationsare allowed.The domain(universe of discourse)must be the set of all integers. Question2(15marks)Three black balls,three red balls and three yellow balls are arranged in a3×3 matrix in such a way that there is no monochromatic row or column(“monochro-matic”refers to balls of the same color).Balls of the same color are considered as indistinguishable.In how many ways can this be done?Question3(15marks)Suppose a1,a2,...,a10are integers satisfying1≤a1≤a2≤···≤a10≤40.Show that there exist distinct3-subsets{i,j,k}and{r,s,t}of{1,2,...,10}such thata i+a j+a k=a r+a s+a t.Question4(20marks)Let G be the simple graph whose vertices are the subsets S⊆{1,2,3,4,5,6,7} with|S|=3,two vertices S and T being adjacent if and only if S∩T=∅.a)How many vertices and edges does G have?b)Is G regular?If applicable,determine its degree.c)Is G connected?d)Is G bipartite?Question5(15marks)a)Find a particular solution of the recurrence relationa n=3a n−1−4a n−3+4n.Hint:The recurrence relation has a solution of the form a n=cn+d,wherec,d are constants.b)Determine the general solution of the recurrence relation in a).Question6(20marks)A list a=(a0,a1,...,a n−1)of integers is said to have a(contiguous)zero subsumif there exist0≤i≤j≤n−1such that a i+a i+1+···+a j=0.a)Write(using a programming language or some form of pseudocode)a booleanfunction has zero subsum(a)with parameter a as above,which returns true if a has a zero subsum and false otherwise.b)Determine the worst-case time complexity of your algorithm,using additionsand comparisons of list elements as basic operations.Both the exact number of basic operations and an asymptotic growth estimate should be given.c)Does there exist a more efficient algorithm for this task?Briefly justify youranswer.Solutions1a)No.1This can be proved either by a truth table or,e.g.,as follows:If p 1is false and p 2is true then p 1↔p 2is false.Hence the disjunction (p 1↔p 2)∨p 1is false as well.4b)No.1For the proof one can use again a truth table or,e.g.,the following shorter argument:p 1→(p 2→p 3)is false for exactly one assigment of truth values to p 1,p 2,p 3,viz.p 1=p 2=T ,p 3=F .On the other hand,(p 1→p 2)→p 3is false whenever p 1=p 3=F (since p 1→p 2=T in this case),and hence for at least twoassigments of truth values (in fact for exactly three).4c)An appropriate formula is¬∃x ∃y ∃z ∃n ¬(xyz =0)∧n ≥3∧(x n +y n =z n ) .51=152Write A for the set of all arrangements of the 9balls (without any restriction)and A i (B j )for the set of arrangements with row i (resp.,column j )monochromatic.Then the desired number is |A \(A 1∪A 2∪A 3∪B 1∪B 2∪B 3)|.2We use the PIE for the computation.The number of unrestricted arrangements is |A |= 93,3,3 = 93 63 =84·20=1680.3Further we have|A i |=|B j |=3 63=60,2|A i,j |=|B i,j |=3!=6,2|A 1,2,3|=|B 1,2,3|=6,3since 2monochromatic rows force the 3rd row to be monochromatic as well.All other intersections between the sets A i ,B j involve at least one A i and at least one B j .Since monochromatic rows and columns exclude each other,these intersectionsare all empty.1It follows that the desired number is1680−6·60+6·6−2·6=1344.22=153The number of distinct 3-subsets of {1,2,...,10}is103 =10·9·83·2·1=120.5The 120sums a i +a j +a k are integers in the range [3,120].There are 118such integers.5=⇒By the pigeonhole principle,since 120>118,the sums cannot be distinct.Hence there exist at least two 3-subsets with the same sum.53=154a)The number of vertices of G is 73 =35.3The number of edges of G is 73 43 ·12=70.Alternatively,use b)and the formulae =vr2for the number of edges of a regular graph.)3b)Yes.The degree of a vertex {a,b,c }is the number of 3-subsets of {1,2,...,7}\{a,b,c },which is a 4-set.Hence G is regular of degree 43 =4.4c)Yes.Consider two non-adjacent vertices S and T .Then |S ∩T |∈{1,2}.1If |S ∩T |=2then |S ∪T |=4and S ,T have a common neighbor,viz.{1,2,...,7}\(S ∪T ).Hence S and T are connected by a path of length 2.2If |S ∩T |=1,let w.l.o.g.S ={1,2,3},T ={1,4,5}.Then,e.g.,M ={4,5,6}is adjacent to S ,N ={2,3,7}is adjacent to T ,and M ,N are adjacent as well.HenceS and T are connected by a path of length 3.2In all G is connected and has diameter 3.d)No.G has cycles of length 7,viz.{1,2,3}→{4,5,6}→{7,1,2}→{3,4,5}→{6,7,1}→{2,3,4}→{5,6,7}→{1,2,3}3Since G has cycles of odd length,G cannot be bipartite.24=205a)The sequence a n =cn +d is a solution if and only if,for every n ,cn +d =3 c (n −1)+d −4 c (n −3)+d +4n=3cn −3c +3d −4cn +12c −4d +4n=(4−c )n +9c −d 2This is in turn equivalent to the system c =4−c ∧d =9c −d ,which has the (unique)solution c =2,d =9.Hence a (p )n =2n +9is a particular solution.3b)The characteristic equation isr 3−3r 2+4=0.2The roots of this equation are 2(of multiplicity 2)and −1(of multiplicity 1).3This can be proved,for example,by checking that 2and −1are solutions,and using the fact that the coefficient of r 2is the negative sum of all three roots.Hence the general solution of the associated homogeneous linear recurrence relation is a(h)n=α1·2n+α2·n2n+α3(−1)n(α1,α2,α3∈C).3 From this and a)thefinal answer isa n=α1·2n+α2·n2n+α3(−1)n+2n+9,whereα1,α2,α3∈C.25=15 6a)def has_subset_sum(a):#a=[a(0),...,a(n-1)]list of integers#We use Python’s convention that indexing starts with0#n denotes the length of the listn=len(a)for i in range(n):#range(n)=[0,...,n-1]sum=0for j in range(i,n):#range(n)=[i,...,n-1]sum=sum+a[j]#Initially sum=a[i]if sum==0:return Truereturn False...10 b)During Pass i through the outer for-loop,the inner for-loop is executed at mostn−i times,with1addition and1comparison per iteration.Hence the total number of basic operations is at mostn−1i=02(n−i)=2n+(n−1)+···+1=n(n+1)=Θ(n2).5(The worst case,n(n+1)operations,occurs if and only if a has no zero subsum except possibly a n−1=0.)c)Yes.Consider the list of partial sums s i=a0+a1+···+a i,0≤i≤n−1,amendedby s−1=0.Then a i+a i+1+···+a j=s j−s i−1,and hence a has a zero subset sum if and only if two elements of the list s=(s−1,s0,s1,...,s n−1)are equal.The list s can be computed in time O(n).Further we can test distinctness of its members in time O(n log n)(by sorting the listfirst,and then checking whether s i< s i+1by one further pass through the list).The total time complexity of this algorithm is only O(n log n).56=20Exam=100。

相关文档
最新文档