Data Str & Algorithm HW Solutions 61

Data Str & Algorithm HW Solutions 61 - 61 / the length...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
61 // the length of the bit vectors are alwasy a number // of ints. void inter(int* in1, int* in2, int* out, int n) { for (int i=0; i<n; i++) out[i] = in1[i] & in2[i]; } // in1 and in2 are input bit vectors, out is output bit // vector; n is length of bit vector in ints. Assume // the length of the bit vectors are alwasy a number // of ints. void diff(int* in1, int* in2, int* out, int n) { for (int i=0; i<n; i++) out[i] = in1[i] & ˜in2[i]; } 9.12 (a) The probability p can be computed as follows: p =1 p 364 363 ∗···∗ 343 365 365 365 50 . 7% . My simulation program give 50.5%. (b) My simulation program gives 64.4% (c) Simplify this problem by assuming that each month has equal prob- ability for having an individual’s birthday. Five students is suf f cient –infac t ,for f ve students the probability of a match is over 60% My
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/27/2011 for the course MAP 2302 taught by Professor Bell,d during the Fall '08 term at UNF.

Ask a homework question - tutors are online