3 Pages

ps4e

Course: CS 504, Fall 2008
School: Uni. Worcester
Rating:
 
 
 
 
 

Word Count: 1009

Document Preview

Analysis CS504: of Computations and Systems Spring 1999 Sample problems, use for exam? March 3, 1999 1. A basketball team has 12 players. In our version of the rules a team is allowed up to 5 exchanges during the entire game, and an exchanged player may not return later. (a) How many different openning-ve sets can the team have? (b) How many different game plans can the team have of each size (the size of a...

Register Now

Unformatted Document Excerpt

Coursehero >> United Kingdom >> Uni. Worcester >> CS 504

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.

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.
Analysis CS504: of Computations and Systems Spring 1999 Sample problems, use for exam? March 3, 1999 1. A basketball team has 12 players. In our version of the rules a team is allowed up to 5 exchanges during the entire game, and an exchanged player may not return later. (a) How many different openning-ve sets can the team have? (b) How many different game plans can the team have of each size (the size of a game plan is the total number of players it uses 5 to 10, naturally)? Total? [A game plan species the opening ve, how many exchanges are to be done, and the identities of the players taking part in each exchange. Order, except among the openning ve, is important.] (c) How is the calculation of part (b) affected when there is one player who is so crucial to this team that no plan ever calls to exchange him... (d) What is the value of P, the probability of a player to play at all, during one game, assuming his likelihood of openning is p0 , and at each exchange the entering player is selected with equal probability from among those yet eligible? Naturally this is a function of the number of exchanges in the game plan. call this number s and write a formula for P in terms of p0 and s. (e) Now assume the manager is strong-headed and plans to use the same number of exchanges s throughout the season (all K games!). What is the probability of the player of part (d) to play at least once during the season? In at least half the games? In all the games? 2. Assume you set out to perform a numerical calculation involving binomial coefcients. (a) You plan to use for them the integer representation provided by the computer (if you were writing in C you would dene them as an array of long ints. Assume thatas is the case in many architecturesthe machine provides you with 32 bits for such a value, in twos complement representation, which means that the largest int it stores is 231 1. What is the largest n for which n k n? k can be thus represented for all 0 (b) Now you are willing to trade off precision for size and use the oating point unit to manipulate these numbers. Hence they are to be stored in the standard oating point representation. We further assume the machine always normalizes before it stores FP numbers and that it uses t bits in the exponent eld of this representation. Further, it uses the excess-exponent representation, which means that the actual exponent is 2t 2 less than the number stored in the exponent eld. Now what is the largest n, as above, given in terms of t? What are the actual values when t 8 12 24 or 32? 3. We have proved in class the Chebyshev inequality. Look at the proof and nd for which kind of random variable inequality the will be achieved as an equality. Explain. CS 504: Sample problems....... 2 4. Show the following sums. Try do it in two ways: directly (where summation by parts could be helpful) and by mathematical induction. k 1 n 2 1 Hn k 1 k 1 n k Hk m n n 1 m 1 k Hk 1 k 1 2 H 2 n The last quantity here, Hn is the nth second-order harmonic number, and equals k n1 1 k2 . 5. Let X be a random variable with the binomial distribution B n p . You may think of it as the number of heads coming up when a coin is ipped n times, where it has the probability of p turning heads up each and every time, independently. Let un (we leave the p implicit in this notation) be the probability that X is even 0 or 2 etc. What is the value of un ? (a) Since the PMF of X is known, you can write a sum for it and compute it directly. This kind of sum is known as bisection, since it picks every other term in a sequence. (b) Another way is to write a recursion for un , by considering how it can depend on un 1 . Write the recursion, solve it, obtain the same value as in part (a). A few problems from the text which I nd suitable... 0 and a0 7. Prob. 2.60, asks to plot a divide and conquer recurrence. Instead, solve it for values of the index which are powers of two. Note that Figs. 2.1 and 2.2 there illustrate the claim I made in class, that it is enough to solve such recurrences for such values of the index in order to track well the evolution of the sequence as it evolves. In truth, this only holds for sequences which increase monotonically (or decrease into the n...

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:

Uni. Worcester - CS - 504
EX: Worst-case # probes for binary search in sorted table of n entries 1, if n = 1 f ( n) = f ( n / 2) +1,if n > 1 DEF : x - largest integer xTry unfolding the recurrence. f ( n) = f ( n / 2) +1= f n / 2 / 2 +1+1 Actually, this is a special cas
Uni. Worcester - CS - 504
Read: GKP 9.1, 9.2 Asymptoticsvoid InsertionSort(A) int A[]; { int i, j, temp; for (j=1; j<Length; j+) /* A[0.j -1] sorted */ for (i=j-1; i>=0 & A[i]>A[i+1]; i-){ temp=A[i]; A[i]=A[i+1]; A[i+1]=temp; } } n=2000, 62 seconds A[j] copied up many times
Uni. Worcester - CS - 504
Binomial Coefficients In how many ways can we choose k elements from an n element set? There are n choices for the first element, n -1 for the second,., down to n-k +1 for the k th , yielding n*(n-1)*.*(n-k+1). So there are 4*3=12 ways to choose 2 el
Uni. Worcester - CS - 504
1+2+3+.+(n -1)+n What is the .? Actually 1+2+.+n suffices. How about 1+2+41.7 ? For a1+a2+.+an, Lagrange(1772) introduced notation.k =1 ak or ak .1kn P(k)nIn general we write akto denote the sum of all ak s.t.:-k integer, -P(k) for p
Uni. Worcester - CS - 504
Read: GKP 8.1,8.2 Quicksort is the sorting technique of choice although its worst-case behavior is inferior to that of many others. pWhy? What does average case mean? Seeking a phone number (which exists) in a phone book sees "on average" half the el
Uni. Worcester - CS - 504
Ex :In how many ways can we give money using 2 coins? (z + z + z + z ) (z + z + z + z ) No! Why not? [z ]( z + z + z + z )( z + z + z + z ) = 25 10 25 5 10 25 6 5 10 25 5 10 25In how many ways can we give money using 1 coin? (z + z + z + z ) [z
Uni. Worcester - CS - 504
Problem : Arithmetic on integers a,b, two n-digit numbers, for large n. Note : Naive addition takes linear time, multiplication quadratic. Can we speed up multiplication at the expense of more additions? Let a = 2,345 = 23*102+45 = a1*102+a2b = 6,
Uni. Worcester - CS - 504
1+2+3+.+(n -1)+n What is the .? Actually 1+2+.+n suffices. How about 1+2+41.7 ? For a1+a2+.+an, Lagrange(1772) introduced notation.k =1 ak or ak .1kn P(k)nIn general we write akto denote the sum of all ak s.t.:-k integer, -P(k) for pr
Uni. Worcester - CS - 504
Ex : Bucket Sorting (Gonnet, 4.2.3, pg. 176) (1-pass version) Assume you know the distribution of a set of keys to be sorted. That is, assume we have M buckets that partition the key space, M keys, and Pr{key belongs in bucket bm} = 1/M , 1m M . for
Uni. Worcester - CS - 504
Read : GKP 8.1,8.2 Quicksort is the sorting technique of choice although its worst-case behavior is inferior to that of many others. Why? What does average case mean? Seeking a phone number (which exists) in a phone book sees "on average" half the el
Uni. Worcester - CS - 504
Given set S, assume each s S has a weight |s|. A GF of S is F ( z) = S an = {s S: s = n} , F ( z) = an z n S NOTE: Since S = a n , S = FS (1) .n ns Szs. LettingEx: In how many ways can we give money using 1 coin? (z + z 5 + z 10 + z 25
Uni. Worcester - CS - 504
CS504: Analysis of Computations and Systems Spring 1999Homework VIDue: March 8 or 10, 1999One more recurrence1. Solve the second-order linear recurrence xn 1 xn 312 xn 32nn2x0a x1bGenerating Functions2. Here is a different w
Uni. Worcester - CS - 99
CS504: Analysis of Computations and Systems Spring 1999Homework VIDue: March 8 or 10, 1999One more recurrence1. Solve the second-order linear recurrence xn 1 xn 312 xn 32nn2x0a x1bGenerating Functions2. Here is a different w
Uni. Worcester - CS - 9906
CS504: Analysis of Computations and Systems Spring 1999Homework VIDue: March 8 or 10, 1999One more recurrence1. Solve the second-order linear recurrence xn 1 xn 312 xn 32nn2x0a x1bGenerating Functions2. Here is a different w
Uni. Worcester - CS - 504
C.S.504 H.W. #7Due: November 5, 1991 1. (3 points) Use the method of characteristic roots to solve the tn = tn -2 + 4n , n 2 recurrence: t 0 = 1, t 1 = 4 2. (3 points) Use the method of characteristic roots to solve the recurrence: tn = 2*tn -1 + (n
Uni. Worcester - CS - 91
C.S.504 H.W. #7Due: November 5, 1991 1. (3 points) Use the method of characteristic roots to solve the tn = tn -2 + 4n , n 2 recurrence: t 0 = 1, t 1 = 4 2. (3 points) Use the method of characteristic roots to solve the recurrence: tn = 2*tn -1 + (n
Uni. Worcester - CS - 504
C.S.504 H.W. #4Due: October 8, 19921. (1 point) Evaluate1 2 n2 +10n2 5 2. (1 point) Evaluate0m kn 3. (4 points) Assume that you're sequentially seeking a card in a perfectly shuffled deck of 106 distinct cards. The card is in the deck. A)W
Uni. Worcester - CS - 92
C.S.504 H.W. #4Due: October 8, 19921. (1 point) Evaluate1 2 n2 +10n2 5 2. (1 point) Evaluate0m kn 3. (4 points) Assume that you're sequentially seeking a card in a perfectly shuffled deck of 106 distinct cards. The card is in the deck. A)W
Uni. Worcester - CS - 504
C.S.504 H.W. #1Due: September 23, 19931. (2 points) What does the following algorithm compute? function f(n,m : integer) : integer; X m; K 0; while Xn do X X*m; K K+1; return(K); 2. (9 points) We want to find the maximum and the minimum element
Uni. Worcester - CS - 93
C.S.504 H.W. #1Due: September 23, 19931. (2 points) What does the following algorithm compute? function f(n,m : integer) : integer; X m; K 0; while Xn do X X*m; K K+1; return(K); 2. (9 points) We want to find the maximum and the minimum element
Uni. Worcester - CS - 504
C.S.504 H.W. #5Due: October 15, 1991 1.(5 points) Prove the equality on page 72 of our text that for direct chaining hashing,s 2 ( A n' ) =2. (3 points) Given two sorted lists,n ( m -1) m2a 1 ,., a n a b 1,.,b nbshow that any algorithm whi
Uni. Worcester - CS - 91
C.S.504 H.W. #5Due: October 15, 1991 1.(5 points) Prove the equality on page 72 of our text that for direct chaining hashing,s 2 ( A n' ) =2. (3 points) Given two sorted lists,n ( m -1) m2a 1 ,., a n a b 1,.,b nbshow that any algorithm whi
Uni. Worcester - CS - 504
C.S.504H.W. #4Due: March 25/26, 1998Read SECTIONS 5.1, 5.2, 5.3 (Trick 1) Do EXERCISEs 5.1, 5.2, 5.4, 5.15 from GKP. Do not submit your solutions, but check them with the answers from the back of the text. 1. (3 points) Find a closed form for coe
Uni. Worcester - CS - 98
C.S.504H.W. #4Due: March 25/26, 1998Read SECTIONS 5.1, 5.2, 5.3 (Trick 1) Do EXERCISEs 5.1, 5.2, 5.4, 5.15 from GKP. Do not submit your solutions, but check them with the answers from the back of the text. 1. (3 points) Find a closed form for coe
Uni. Worcester - CS - 504
C.S.504 H.W. #1Due: September 17, 1991 Assume that you're sequentially seeking a card in a perfectly shuffled deck of 106 distinct cards. Use Chebyshev's inequality to give a bound on the probability that you'll have to examine at least 900,000 card
Uni. Worcester - CS - 91
C.S.504 H.W. #1Due: September 17, 1991 Assume that you're sequentially seeking a card in a perfectly shuffled deck of 106 distinct cards. Use Chebyshev's inequality to give a bound on the probability that you'll have to examine at least 900,000 card
Uni. Worcester - CS - 504
C.S.504SOLUTION FOR H.W. #1k n n n n( n +1) n( n - 1) n 1 - 1 = ( n - k) = n - k = n 2 = 1. 1 = 2 2 k =1 j =k+ 1 k =1 j =1 j =1 k =1 k =1 k =1 n n n2. In fact, Gn = (-1)n+1Fn.0, if n = 0 Gn = if n = 1 1, G - G , if n >1 n -2 n -13.
Uni. Worcester - CS - 98
C.S.504SOLUTION FOR H.W. #1k n n n n( n +1) n( n - 1) n 1 - 1 = ( n - k) = n - k = n 2 = 1. 1 = 2 2 k =1 j =k+ 1 k =1 j =1 j =1 k =1 k =1 k =1 n n n2. In fact, Gn = (-1)n+1Fn.0, if n = 0 Gn = if n = 1 1, G - G , if n >1 n -2 n -13.
Uni. Worcester - CS - 504
C.S.504 H.W. #2Due: September 24, 1992(6 points) Consider the following procedure void InsertionSort(int A, int n) {int i, j,temp; for (i=1; i<n; i+) { /* A[0.i-1] already sorted */ temp=A[i]; for (j=i-1; j>=0 & temp<A[j]; j-) A[j+1]=A[j]; /*<-*/ A
Uni. Worcester - CS - 92
C.S.504 H.W. #2Due: September 24, 1992(6 points) Consider the following procedure void InsertionSort(int A, int n) {int i, j,temp; for (i=1; i<n; i+) { /* A[0.i-1] already sorted */ temp=A[i]; for (j=i-1; j>=0 & temp<A[j]; j-) A[j+1]=A[j]; /*<-*/ A
Uni. Worcester - CS - 504
C.S.504 H.W. #3Due: October 21, 1993 1. (5 points) We define an Isaac tree In recursively by: -I0 consists of a single node, -the Isaac tree In, n1, consists of two Isaac trees In-1 such that the root of one is the rightmost child of the root of the
Uni. Worcester - CS - 93
C.S.504 H.W. #3Due: October 21, 1993 1. (5 points) We define an Isaac tree In recursively by: -I0 consists of a single node, -the Isaac tree In, n1, consists of two Isaac trees In-1 such that the root of one is the rightmost child of the root of the
Uni. Worcester - CS - 504
C.S.504 H.W. #10Due: Tuesday, December 15, 1992 1. (8 points) One way to estimate the size of a set X ={ x 1 ,., x n } is to sample the elements of X from a uniform distribution with replacement until an element is sampled twice. The number of eleme
Uni. Worcester - CS - 92
C.S.504 H.W. #10Due: Tuesday, December 15, 1992 1. (8 points) One way to estimate the size of a set X ={ x 1 ,., x n } is to sample the elements of X from a uniform distribution with replacement until an element is sampled twice. The number of eleme
Uni. Worcester - CS - 504
C.S.504SOLUTION FOR H.W. #5 1. (A) If we restrict the composition to have one part (k=1), then the GF is z + + z r . For 1 an arbitrary number of parts (no restrictions on k), the GF is . 1- z - - z r 1 (B) fn ,2 = z n F2 ( z) = z n . Recognizing, y
Uni. Worcester - CS - 98
C.S.504SOLUTION FOR H.W. #5 1. (A) If we restrict the composition to have one part (k=1), then the GF is z + + z r . For 1 an arbitrary number of parts (no restrictions on k), the GF is . 1- z - - z r 1 (B) fn ,2 = z n F2 ( z) = z n . Recognizing, y
Uni. Worcester - CS - 504
C.S.504H.W. #2Due: February 11/12, 19981. (6 points) Find a closed form solution for the linear first-order nonhomogeneous recurrence with nonconstant coefficients 0,if n = 0 xn = n + 3 x + n + 3,if n > 0 n +1 n -1 2 The first three terms are
Uni. Worcester - CS - 98
C.S.504H.W. #2Due: February 11/12, 19981. (6 points) Find a closed form solution for the linear first-order nonhomogeneous recurrence with nonconstant coefficients 0,if n = 0 xn = n + 3 x + n + 3,if n > 0 n +1 n -1 2 The first three terms are
Uni. Worcester - CS - 504
C.S.504 H.W. #3Due: October 1,1991 1.(2 points) In Section 3.1.1 of our text, what is E[An ] when Pr{An =i } = if 1i n -1 then (1/2)i else if i =n then (1/2)n -1. 2. (3 points) Prove that0 k <n 0k <n for n 0. 3. (2 points) Suppose a program has
Uni. Worcester - CS - 91
C.S.504 H.W. #3Due: October 1,1991 1.(2 points) In Section 3.1.1 of our text, what is E[An ] when Pr{An =i } = if 1i n -1 then (1/2)i else if i =n then (1/2)n -1. 2. (3 points) Prove that0 k <n 0k <n for n 0. 3. (2 points) Suppose a program has
Uni. Worcester - CS - 504
C.S.504H.W. #5Due: April 8/9, 1998Read SECTIONS 7.1, 7.2, 7.3, 7.5 Do EXERCISEs 7.1, 7.2, 7.3, 7.4, 5.15 from GKP. Do not submit your solutions, but check them with the answers from the back of the text. 1. (4 points) Define an r-composition of n
Uni. Worcester - CS - 98
C.S.504H.W. #5Due: April 8/9, 1998Read SECTIONS 7.1, 7.2, 7.3, 7.5 Do EXERCISEs 7.1, 7.2, 7.3, 7.4, 5.15 from GKP. Do not submit your solutions, but check them with the answers from the back of the text. 1. (4 points) Define an r-composition of n
Uni. Worcester - CS - 504
C.S.504 H.W. #3Due: October 1, 19921. (6 points) You should compare three techniques for evaluating the 1 integral 4 1- x 2 d x . For each of the techniques, you should test the 0 rate of convergence by comparing the influence of n upon the accu
Uni. Worcester - CS - 92
C.S.504 H.W. #3Due: October 1, 19921. (6 points) You should compare three techniques for evaluating the 1 integral 4 1- x 2 d x . For each of the techniques, you should test the 0 rate of convergence by comparing the influence of n upon the accu
Uni. Worcester - CS - 504
Due: December 16, 1993C.S.504 H.W. #71. (5 points) Solve the recurrence kfn k , if > 0 n 0k fn = 1, n if = 0 0, if < 0 n ( Hints : -One solution could parallel the text's solution to its recurrence (7.41). -The summation is a convolution. )
Uni. Worcester - CS - 93
Due: December 16, 1993C.S.504 H.W. #71. (5 points) Solve the recurrence kfn k , if > 0 n 0k fn = 1, n if = 0 0, if < 0 n ( Hints : -One solution could parallel the text's solution to its recurrence (7.41). -The summation is a convolution. )
Uni. Worcester - CS - 504
C.S.504 H.W. #5Due: October 15, 1992 1. (3 points) Find simple forms for 1k n( 2k - 1 )and0k(k- 1 ) . 2k2. (2 points) Show that1k 3. (5 points) Robin hood hashing is used to reduce the variance of the expected successful search time for
Uni. Worcester - CS - 92
C.S.504 H.W. #5Due: October 15, 1992 1. (3 points) Find simple forms for 1k n( 2k - 1 )and0k(k- 1 ) . 2k2. (2 points) Show that1k 3. (5 points) Robin hood hashing is used to reduce the variance of the expected successful search time for
Uni. Worcester - CS - 504
C.S.504 H.W. #1Due: September 17, 1992 1. (1 point) What is (0.125)-2/3? 2. (4 points) Given array A[1.n] of integers such that |A[k+1]-A[k]|1 for 1k<n and given integer x such that A[1]xA[n], we seek a j, 1jn, such that A[j]=x. Describe an algorith
Uni. Worcester - CS - 92
C.S.504 H.W. #1Due: September 17, 1992 1. (1 point) What is (0.125)-2/3? 2. (4 points) Given array A[1.n] of integers such that |A[k+1]-A[k]|1 for 1k<n and given integer x such that A[1]xA[n], we seek a j, 1jn, such that A[j]=x. Describe an algorith
Uni. Worcester - CS - 504
C.S.504 H.W. #9Due: December 3, 1992 1. (3 points) A) Give a generating function, F m ( z ), for the number of ways to put indistinguishable balls into m distinguishable boxes, such that each box contains at least one ball. [z n ] F m ( z ) is the n
Uni. Worcester - CS - 92
C.S.504 H.W. #9Due: December 3, 1992 1. (3 points) A) Give a generating function, F m ( z ), for the number of ways to put indistinguishable balls into m distinguishable boxes, such that each box contains at least one ball. [z n ] F m ( z ) is the n
Uni. Worcester - CS - 99
CS504: Analysis of Computations and Systems Spring 1999Homework II with Solution Probability Problems1. Two true dice are rolled. One is known to show an even number. What is the probability that the sum of both is 8? That it is 9? Solution: Sinc
Uni. Worcester - CS - 9902
CS504: Analysis of Computations and Systems Spring 1999Homework II with Solution Probability Problems1. Two true dice are rolled. One is known to show an even number. What is the probability that the sum of both is 8? That it is 9? Solution: Sinc
Uni. Worcester - CS - 99
CS504: Analysis of Computations and Systems Spring 1999Homework IIDue: February 8 or 10, 1999Probability Problems1. Two true dice are rolled. One is known to show an even number. What is the probability that the sum of both is 8? That it is 9?
Uni. Worcester - CS - 9902
CS504: Analysis of Computations and Systems Spring 1999Homework IIDue: February 8 or 10, 1999Probability Problems1. Two true dice are rolled. One is known to show an even number. What is the probability that the sum of both is 8? That it is 9?
Uni. Worcester - CS - 99
CS504: Analysis of Computations and Systems - Spring 1999Homework VIII - with solution1. Let an be the number of ways to obtain the score n by throwing a die. For example, a3 4. This corresponds to the possible throw sequences 1,1,1; 1,2; 2,1; 3. F
Uni. Worcester - CS - 9908
CS504: Analysis of Computations and Systems - Spring 1999Homework VIII - with solution1. Let an be the number of ways to obtain the score n by throwing a die. For example, a3 4. This corresponds to the possible throw sequences 1,1,1; 1,2; 2,1; 3. F
Uni. Worcester - CS - 504
CS504: Analysis of Computations and Systems - Spring 1999Homework VI - with SolutionThis may be as good a place as any to repeat that when you submit a home assignment or an exam you should show all work. Otherwise, when a result seems to appear "o
Uni. Worcester - CS - 99
CS504: Analysis of Computations and Systems - Spring 1999Homework VI - with SolutionThis may be as good a place as any to repeat that when you submit a home assignment or an exam you should show all work. Otherwise, when a result seems to appear "o
Uni. Worcester - CS - 504
CS504Name_ Midterm ExamDate : October 22, 1992 All documentation permitted 1(10 points) The product of polynomials A=an xn + an -1xn-1 +.+ a1x +a0 and B=bmxm + bm -1xm-1 +.+ b1x +b0 is polynomial C=cn +mxn+m + cn+m -1xn+m-1 +.+ c1x +c0 where ci =