mt2(4) - CS 373 U Midterm 2 Questions (April 6, 2004)...

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

View Full Document Right Arrow Icon
CS 373 U Midterm 2 Questions (April 6, 2004) Spring 2004 Write your answers in the separate answer booklet. 1. A data stream is an extremely long sequence of items that you can only read only once, in order. A good example of a data stream is the sequence of packets that pass through a router. Data stream algorithms must process each item in the stream quickly, using very little memory; there is simply too much data to store, and it arrives too quickly for any complex computations. Every data stream algorithm looks roughly like this: DoSomethingInteresting (stream S ): repeat x next item in S aa do something fast with x AA until S ends return aa something AA Describe and analyze an algorithm that chooses one element uniformly at random from a data stream, without knowing the length of the stream in advance . Your algorithm should spend O (1) time per stream element and use O (1) space (not counting the stream itself). Assume you have a subroutine Random ( n ) that returns a random integer between 1 and
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 note was uploaded on 01/22/2012 for the course CS 573 taught by Professor Chekuri,c during the Fall '08 term at University of Illinois, Urbana Champaign.

Page1 / 2

mt2(4) - CS 373 U Midterm 2 Questions (April 6, 2004)...

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