lec6 - Lecture 6 Randomized data structures Random number...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Page 1 of 44 CSE 100, UCSD: LEC 6 Lecture 6 Randomized data structures Random number generation Skip lists: ideas and implementation Skip list time costs Reading: “Skip Lists: A Probabilistic Alternative to Balanced Trees” paper (Pugh); Weiss, Chapter 10 section 4
Background image of page 1

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

View Full DocumentRight Arrow Icon
Page 2 of 44 CSE 100, UCSD: LEC 6 Deterministic and probabilistic data structures Most typical data structures are deterministic data structures: starting with an empty structure and a sequence of insert, find, and delete operations with specific key values, you will always get exactly the same resulting structure In the last few years, there has been a lot of interest in probabilistic, or randomized, data structures: in a probabilistic data structure, the same sequence of operations will usually not result in the same structure; it depends on the sequence of random bits generated during the operations It turns out that these probabilistic data structures can work about as well as the best deterministic ones, but can be much easier to implement Skip lists and randomized search trees are examples of randomized data structures We will look at skip lists in a moment But first, we will briefly discuss random number generation
Background image of page 2
Page 3 of 44 CSE 100, UCSD: LEC 6 Random number generation Random numbers are useful in many applications: cryptography, software testing, games, probabilistic data structures, etc. A truly random number would be truly unpredictable However, ordinary programs are deterministic, and therefore their outputs are predictable! So, you can’t write an ordinary program to generate truly random numbers; you generate pseudo random numbers (you could connect your computer to a nonalgorithmic device and collect truly random bits from it; see /dev/random on Unix systems, or various web services) A typical pseudorandom number generator (RNG) is initialized with a seed; if the seed is truly random, the RNG will have as much randomness as there is in the seed Though the generated numbers aren’t truly random, they should appear quite random. .. what does that mean?
Background image of page 3

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

View Full DocumentRight Arrow Icon
Page 4 of 44 CSE 100, UCSD: LEC 6 Tests for randomness A good pseudorandom number generator (RNG) will generate a sequence of numbers that will pass various statistical tests of randomness. .. the numbers will appear to be random, and can be used in many applications as if they were truly random Some good properties of a random sequence of numbers: Each bit in a number should have a 50% probability of changing (1->0 or 0->1) when going from one number to the next in the sequence The sequence of numbers should not repeat at all, or if the numbers do cycle, the cycle should be very (very!) long How to write a program that generates good pseudorandom numbers? One common approach is the linear congruential RNG
Background image of page 4
Page 5 of 44 CSE 100, UCSD: LEC 6 Linear congruential RNG’s A typical pseudorandom number generator works like this: The RNG is initialized by setting the value of a “seed”
Background image of page 5

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

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

Page1 / 44

lec6 - Lecture 6 Randomized data structures Random number...

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

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