Data Structures & Alogs HW_Part_16

Data Structures & Alogs HW_Part_16 - 61 / the length of...

Info iconThis preview shows pages 1–2. 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 simulation program gives 42.9% for 4 people, and 62.2% for 5 people. 9.13 (a) No–if K n 2 then the result will be out of the range of the hash table. (b) Yes –but is the worst possible hash function since all values hash to the same location.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 10/31/2011 for the course BCN 3431 at University of Florida.

Page1 / 4

Data Structures & Alogs HW_Part_16 - 61 / the length of...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online