Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more.
Course Hero has millions of course specific materials providing students with the best way to expand
their education.
Below is a small sample set of documents:
McMaster - CAS - 2c03
Question 6[5] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 133 20 383 22 156 784 9999 82 144787 674 176 845 11 31 1230 122622 35 416 94Question 7[5] h(k ) = 506 k ( 51 2)mod 1h(51) = 262, h(52) = 69, h(53) = 382, h(54) = 189, h(55) = 501. Questio
McMaster - CAS - 2c03
9.[15] a.[5] Show the heap (partially ordered tree) that results if the integers 8, 7, 5, 6, 10, 2, 1, 3, 11, 9, 4 are inserted into an empty tree.b[10]. What is the result of 5 successive DELETEMIN operations on the tree from (a)?1
McMaster - CAS - 2c03
Question 10[10] 8 7 5 (a) 2 1 3 4 6 6 9 11 9 10 8 11 (b) 7 102
McMaster - CAS - 2c03
11.[10]Give an example of a binary search tree which is a complete tree. Can it be done for an arbitrary number of nodes? Prove your answer.Yes. First, construct complete tree with n nodes. Get the inorder list of the complete tree, say, a1,a2,an. Let a
McMaster - CAS - 2c03
insertion:n(n + 1) = O(n 2 ) 2 i =1 inorder walk takes O(n) therefore total time: O(n 2 )i =nBest case: O(n lg n) : when tree growth is balanced, each insertion takes O(lg n) ,we have n insertion therefore total insertion takes O(n lg n) inorder walk
McMaster - CAS - 2c03
SE2C03. Sample solutions to the assignment 3. Total of this assignment is 274pts. 100%=254. Each assignment is worth 5%. If you think your solution has been marked wrongly, write a short memo stating where marking in wrong and what you think is right, and
McMaster - CAS - 2c03
2.[30] AVL trees are a good implementation of binary search trees. Show (step by step) the AVL trees formed by inserting the numbers 10, 9, 8, 7, 6, 5, 4, 3, 2, 1. 10 10 insert(10) insert(9) 9 8 9 insert(6) 8 7 6 10 6 9 repair 7 8 5 insert(5) 10 6 7 8 10
McMaster - CAS - 2c03
7 repair 5 3 2 4 1 6 8 9 10 2 3 4 inset(1) 57 repair 9 6 8 10 1 2 4 37 9 5 8 6 103.[20] a[10], b[10], Solutions at the end. 4.[10] Consider ADT Sets with the following operations: MEMBER, DELETE, INSERT. Show that a heap is not an efficient way to impl
McMaster - CAS - 2c03
5.[15] Consider ADT Sets with the following operations: MEMBER, DELETE, INSERT, UNION, MERGE. Show that a binary search trees are not an efficient way to implement this ADT. What about 2-3 trees or red-black? Which operation is the most problematic? Provi
McMaster - CAS - 2c03
6.[25] Consider ADT Sets (of numbers) with the following operations: MEMBER(x), DELETEMIN, INSERT(x), DELETEMAX, and MEDIAN, which is a function integer greater than or equal to x, i.e. 3.1 = 4, 4 = 4. What model(s) would you recommend and why? Provide bi
McMaster - CAS - 2c03
8.[10] a[5] If team 1 needs i games to win, then it has won n-i games already. Thus, we obtain the following recurrence: P(i, j) = 1 0 pn-i(P(i-1,j)+(1- pn-i(P(i,j-1) if i=0 and j>0 if i>0 and j=0 if i>0 and j>0b[5] (i,j) 0 1 2 3 4 0 0 1 1 1 1 1 0 0.5 0.
McMaster - CAS - 2c03
b. Assume T(k,k)=T(j,0)=c for all j,k, and for making reasoning easier T(i,j)=0 if j<0. T(n,m)=T(n-1,m)+T(n-1,m-1)+1 (n,m) / (n-1,m) / \ (n-2,m) (n-2,m-1) . \ (n-1,m-1) / \ (n-1,m-1) (n-2,m-2)One solution, by using recursion tree in pure form: In the wor
McMaster - CAS - 2c03
Hence: T(n,m) (C(0,k)+C(1,k)+.+C(i,k)+.+C(k,k) c + (2k+1-1)c = 2k c + (2k+1-1)c = (32k 1)c = (32n/2 1)c = O(2n/2). One also may suspect O(2n/2) solution, and prove it by induction. c. we use the recursive formulation, to fill entries of the table like the
McMaster - CAS - 2c03
int Factorial(int n)cfw_ int f=1; for(int i=1;i<=n;i+) f*=i; return f; /DnC implements solution to 10(a). it uses divide and conquer method int DnC(int n,int m)cfw_ if(m=0 | n=m) return 1; else return DnC(n-1,m)+DnC(n-1,m-1); /DP implements solution to
McMaster - CAS - 2c03
12.[10] Suppose characters a, b, c, d, e, f, g, h, i, j have probabilities 0.02, 0.02, 0.03, , 0.04, 0.05, 0.10, 0.10, 0.13, 0.20, 0.31, respectively. Construct an optimal Huffman code and draw the Huffman tree. Use the following rules: a. Left: 0, right:
McMaster - CAS - 2c03
13.[20] Suppose T is a Huffman tree, and that the leaf for symbol a has greater depth than the leaf for symbol b. Prove that the probability of symbol b is no less than that of a. It can be proven in many ways by induction. The simplest seems to be the fo
McMaster - CAS - 2c03
Another possible solution, in the similar style is the following. For any Huffman tree, if we combine two leaves, and use another symbol to represent it. Assigning the sum of probability of two leaves to the new symbol, we get a new Huffman tree for a new
McMaster - CAS - 2c03
Now, we suppose prob(a) > prob(b), which means a is not used before b is used in construction of Huffman tree. These imply that prob(a) > prob(T), because prob(b) and prob(T) must be the smallest two ones. With the same reason, prob(c) > prob(b), pro(T),
McMaster - CAS - 2c03
16.[20] Suppose we use the 2-3 trees to implement the WMERGE (i.e. a MERGE(A,B), but the set is totally ordered and all the elements of A are smaller than the elements of B) and SPLIT. a.[10] Show the result of splitting the tree of Question (1a) at 7. 25
McMaster - CAS - 2c03
Question 3 5 1 0 2 3 4 6 7 8 10 9 11 12 13 After deletions: 5 1 0 2 4 6 7 8 10 9 11 12Question 9 8 2 5 10 j f1 [j ] f2 [j ] l1 [j ] l2 [j ] 1 10 15 2 20 19 1 1 3 22 26 1 3 2 6 4 27 27 1 1 5 36 33 1 2 6 39 41 2 2 10 2 1 7 7 49 47 1 2 8 52 52 2 2 1 3 4 5 4
McMaster - CAS - 2c03
Question 14 (a) 519110 After deletions:234678101213519110 (b)2467810122690 After deletions:134578101112132690 (c)14578101112590 After deletions:1234678101112135901246781011122
McMaster - CAS - 2c03
SE2C03. Sample solutions to the assignment 4. Total of this assignment is 231 pts. 100%= 205. Each assignment is worth 5%. If you think your solution has been marked wrongly, write a short memo stating where marking in wrong and what you think is right, a
McMaster - CAS - 2c03
Using KMPabaAbabaababbababaaababaababb pass1 a b b pass2 aB pass3 Abb pass4 abb pass5 ab pass6 abb pass7 abbababaaabab # of comparisons 3 2 3 3 2 3 13 Total 293.[16] Abstract Data Type DIGRAPH involves the following 3 operations on directed graphs : FIR
McMaster - CAS - 2c03
b.[8] Linked adjacency lists Assume the ADT LIST is defined with proper functions implemented. function FIRST(v:integer): position begin return(FIRST_LIST(A[v]) end function NEXT(v:integer, i:position): position begin return(NEXT_LIST(A[v],i) end function
McMaster - CAS - 2c03
a.[5] a a b c d e f g h i b[5] a [b,5,nil] b [c,1] [d,3,nil] c [a,3] [d,2] [e,3] [h,2,nil] d [a,4] [b,4,nil] e [b,2] [d,3] [f,2] [i,4,nil] f [b,1] [d,2,nil] g [b,1] [c,3,nil] h [d,2] [g,3,nil] i [a,1,nil] 3 4 b c 1 4 2 1 1 d 3 2 3 2 3 2 1 3 e 3 2 f 5 g h
McMaster - CAS - 2c03
7.[20] A root of a directed acyclic graph (dag) is a vertex r such that every vertex of the dag can be reached by a directed path from r. Write a program to determine whether a dag is rooted. Assume that the dag is represented using adjacency lists. Make
McMaster - CAS - 2c03
10.[10]Use a depth-first search algorithm to identify all the articulation vertices and biconnected components in the graph from Question 9. Draw an appropriate depth-first graph and indicate all the low and dfnumber values.A solution at the end11.[15]
McMaster - CAS - 2c03
A possible solution M cfw_(A,I) cfw_(A,I),(B,G) cfw_(A,I),(B,G),(C,J) cfw_(A,I),(B,G),(C,J),(E,K) cfw_(A,I),(B,G),(C,J),(E,K),(M,N) cfw_(A,I),(B,H),(C,J),(D,G),(E,K),(M,N) cfw_(A,I),(B,H),(C,J),(D,G),(E,K),(F,J),(M,K) augmenting path relative to M A-I B-G
McMaster - CAS - 2c03
Question 5(a)a 1/18/1b 3/16/3g 12/13/9f 2/17/2c 4/15/4i 8/9/7e 7/10/6d 5/6/5h 11/14/8Tree edges are black, back edges are red, forward edges are green and cross edges are blue. The numbers in each vertex are (d[v ]/f [v ]/dfnumber[v ]). Question
McMaster - CAS - 2c03
Question 8 Assuming alphabetical ordering, the solution is:A 1/12 B 2/3 C 4/5O 28/29H 14/17I 15/16G 13/18 D 7/8 F 6/11 E 9/10 N 25/26J 19/30K 20/21L 22/27M 23/24Ordering by decreasing nishing times gives the topological sorting:JOLNMKGH
McMaster - CAS - 2c03
(c) Depth-rst spanning tree (costs ignored):a f51b2g c3 8i6e4d7h(d) Breadth-rst spanning tree (costs ignored):1a1 1 11b2g c2f i e2dhQuestion 10 We use the depth-rst spanning tree from question 9(c), and redraw it to highlight t
McMaster - CAS - 2c03
SE2C03. Sample solutions to the assignment 5. Total of this assignment is 75pts. 100% equals 65. Each assignment is worth 5%. If you think your solution has been marked wrongly, write a short memo stating where marking in wrong and what you think is right
McMaster - CAS - 2c03
Question 1 Dijkstras algorithms works as follows if alphabetical ordering (as in the last assignment) is assumed. Edges are numbered in the order that they are added.3 a 0 1 f 5 2 e 10 d 7 7 c 7 6 i 14 9 h 9 8 b 6 4 g 12The array is as follows. [a] [b]
McMaster - CAS - 2c03
A3 =0 3 3 64 6 65 44 4 72 0 4 2 1 1 1 0 5 3 2 2 3 2 0 3 2 4 2 4 3 8 0 5 5 5 8 8 9 2 0 9 12 0 3 3 2 7 5 4 4 0 7 7 47 5 03 A4 =20 3 3 64 6 65 44 4 6 7 0 6 4 2 1 1 6 1 0 5 3 2 2 7 3 2 0 3 2 4 2 4 3 8 0 5 5 10 5 8 8 9 2 0 9 11 12 0 3 3 2
McMaster - CAS - 2c03
9v14 6 15 104v3817 4v54 8 96s5t152v212v43v69v14 6 12 104v3817 4v54 8 9 126s35 9 3t32v2v43v69v14 6 4 104v38 217 4v54 8 46s115 1 111 8 3t11v2v4v6No more augmenting paths exist, so we are done. Quest
McMaster - CAS - 2c03
CS2MD3. Sample solutions to the assignment 1. Total of this assignment is 132pts. Each assignment is worth 5%. If you think your solution has been marked wrongly, write a short memo stating where marking in wrong and what you think is right, and resubmit
McMaster - CAS - 2c03
2.[11] Using only definition of O(f(n) proof that the following statements are true: 1.[2] 7000n2n/(n2 + 3) = O(2n) Let c=1, n0=7000. For all n 7000, 7000n2n/(n2 + 3) 7000n2n/(7000n + 3) 2n. 2.[3] 100n32n + 6n23n = O(4n) Let c=106, n0=16=24. First n3 = 23
McMaster - CAS - 2c03
For all n n0, n*log (3/2) log c, then (3/2)n c. Hence, 3n = (3/2)n * 2n c*2n. d.[2] log n + n1/2 = O(log n) For all c 0, take n0 = c4. For all n n0, log n + n1/2 log c + n1/4*n1/4 log c + c*n1/4 c*log n hold.4.[12] Consider lists of integers. The lexicog
McMaster - CAS - 2c03
p1 := FIRST(L1); p2 := FIRST(L2); while (p1 <> END(L1) and p2 <> END(L2) do begin x1 := RETRIEVE(p1, L1); x2 := RETRIEVE(p2, L2); if (x1 < x2) then return(true) else if (x1 > x2) then return(false) else begin p1 := NEXT(p1, L1); p1 := NEXT(p1, L1) end end
McMaster - CAS - 2c03
for j:=3005 to 2*n*n do begin C[i,j]:=0; for k:=n/5 to 3*n do C[i,j]:=C[i,j]*A[i,k]; for k:=n to n*n do C[i,j]:=C[i,j] + A[i,k]*B[k,j]; for k:=1 to n/2 do C[i,j]:=C[i,j]*A[i,k]; end end else begin C[i,j]:=A[i,j]; for k:=n*n/3 to n*n/2 do C[i,j]:=C[i,j]*A[
McMaster - CAS - 2c03
T1(n) = C + 2*T1 (n - 3) = (1+2)C +22T1 (n 3*2) = (1+2+22)C +23T1 (n - 3*3). = (1+2+22+2n/3-1)C +2n/3T1 (1) where m ~ logn/log3 = 2n/3*C + 2mC = O(2n/3) T2(n) = C + 2*T2 (n - 1) = (1+2)C +22T2 (n - 2) = (1+2+22)C +23T2 (n - 3). = (1+2+22+2(n-1)C +2nT1 (1)
McMaster - CAS - 2c03
while (p .next <> nil) do begin if (n mod 3 = 0) or (n mod 3 = 2) the begin p .next := p .next .next; n:= n+1;end p := p .next ; n:= n+1; end end The time complexity is O(n). b.[5] SHUFFLE(L1,L2). This procedure shuffles the list, the result has the appro
McMaster - CAS - 2c03
while (p .next <> nil) do begin tmp := p .next; p .next := p2 .next .next; tmp .next := L .next .next; L .next .next := tmp; p1 := p1 .next .next ; p2 .next := tmp2 ; end end The time complexity is O(n). d.[5] Assume that the list are doubly linked and re
McMaster - CAS - 2c03
begin L.last := (L.last - 1) div 3) + 1; for (n :=2 to L.last) do begin L.element[n] := L.element[3n-2] end end The time complexity is O(n). b.[5] SHUFFLE(L1,L2). This procedure shuffles the list, the result has the appropriate elements of the first list
McMaster - CAS - 2c03
L[p] := L[q]; L[q] := tmp; p := p + 1 ; q := q-1 end end The time complexity is O(n).8.[15] Using the operations given on pages 38-39 of Aho-Hopcroft-Ullman, write procedures to compute the functions from question 6. [5] procedure 3ONLY(var L: List;); va
McMaster - CAS - 2c03
var p,q: position; tmp: elementtype; begin if (FIRST(L)=END(L) or NEXT(FIRST(L),L)=END(L) or NEXT(NEXT(FIRST(L),L),L)=END(L) return; p := NEXT(FIRST(L),L); q := NEXT(p,L); while (q <> END(L) do begin INSERT(RETRIEVE(q,L), p, L); DELETE(NEXT(p,L),L); q :=
McMaster - CAS - 2c03
CS2MD3. Sample solutions to the assignment 2. Total of this assignment is 122pts. Each assignment is worth 5%. If you think your solution has been marked wrongly, write a short memo stating where marking in wrong and what you think is right, and resubmit
McMaster - CAS - 2c03
Using find 2abbbabbaabbabaab a baabaabaababbabbbabba pass1 a b a pass2 a pass3 a pass4 aba pass5 a pass6 ab pass7 aba pass8 a pass9 abaab a a pass10 (a b a) a pass11 (a) b a a b a a b a b pass12 (a b a a b a) a b a b # 3 1 1 3 1 2 3 1 7 1 9 4 362[15]. A
U. Houston - PSYCH - 1300
U. Houston - PSYCH - 1300
U. Houston - PSYCH - 1300
U. Houston - PSYCH - 1300
U. Houston - PSYCH - 1300
U. Houston - PSYCH - 1300
U. Houston - PSYCH - 1300
U. Houston - PSYCH - 1300
Purdue - CNIT - 176
CIT 176 Exam 1 ReviewChapter 1: Your Need to Know Systems Development Life Cycle (SDLC)- process of creating or altering systems. The series of steps IS professionals follow when developing an IS. Unified Process- A modern SDLC. Under the SDLC, an IS is
Santa Barbara City - ECE - 210a
University of California, Santa BarbaraDepartment of Electrical & Computer EngineeringECE 210a, Math 206a, CMPSC 211a, ME 210a, ChE 211a Matrix Analysis and Computation Fall 2009Homework 1.Problem 1. Find a basis for the following vector spaces: 1. Th