11.07.2015 Views

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Sec. 8.8 Projects 299an external sorting algorithm is used. The company’s payroll program is sogood th<strong>at</strong> it plans to hire out its services to do payroll processing for othercompanies. The president has an offer from a second company with 100times as many employees. She realizes th<strong>at</strong> her computer is not up to thejob of sorting 100 times as many records in an acceptable amount of time.Describe wh<strong>at</strong> impact each of the following modific<strong>at</strong>ions to the computingsystem is likely to have in terms of reducing the time required to process thelarger payroll d<strong>at</strong>abase.(a) A factor of two speedup to the CPU.(b) A factor of two speedup to disk I/O time.(c) A factor of two speedup to main memory access time.(d) A factor of two increase to main memory size.8.22 How can the external sorting algorithm described in this chapter be extendedto h<strong>and</strong>le variable-length records?8.8 Projects8.1 For a d<strong>at</strong>abase applic<strong>at</strong>ion, assume it takes 10 ms to read a block from disk,1 ms to search for a record in a block stored in memory, <strong>and</strong> th<strong>at</strong> there isroom in memory for a buffer pool of 5 blocks. Requests come in for records,with the request specifying which block contains the record. If a block isaccessed, there is a 10% probability for each of the next ten requests th<strong>at</strong> therequest will be to the same block. Wh<strong>at</strong> will be the expected performanceimprovement for each of the following modific<strong>at</strong>ions to the system?(a) Get a CPU th<strong>at</strong> is twice as fast.(b) Get a disk drive th<strong>at</strong> is twice as fast.(c) Get enough memory to double the buffer pool size.Write a simul<strong>at</strong>ion to analyze this problem.8.2 Pictures are typically stored as an array, row by row, on disk. Consider thecase where the picture has 16 colors. Thus, each pixel can be represented using4 bits. If you allow 8 bits per pixel, no processing is required to unpackthe pixels (because a pixel corresponds to a byte, the lowest level of addressingon most machines). If you pack two pixels per byte, space is saved butthe pixels must be unpacked. Which takes more time to read from disk <strong>and</strong>access every pixel of the image: 8 bits per pixel, or 4 bits per pixel with2 pixels per byte? Program both <strong>and</strong> compare the times.8.3 Implement a disk-based buffer pool class based on the LRU buffer pool replacementstr<strong>at</strong>egy. Disk blocks are numbered consecutively from the beginningof the file with the first block numbered as 0. Assume th<strong>at</strong> blocks are

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!