Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solve this problem with dynamic programming. Identify the base case, dynamic array, and solution, then write a program in python to solve the following problem.

image text in transcribed

Solve this problem with dynamic programming. Identify the base case, dynamic array, and solution, then write a program in python to solve the following problem. In the olden days of computing, files were stored on disk drives. Disk drives are spinning disks. Roughly, data is stored in concentric circles and can be read or written by moving the disk head to the location of the data and, as the disk spins under it, the data at that location is read. Consider a disk drive with n locations (think of these locations as distances from the center of the disk). Consider serving a sequence of m requests given by locations r = r 1...,m in the order that they arrived. Suppose the read head that starts at position ro = 1. It takes time to physically move the head from one location to another and that access time is proportional to the distance between the locations. Thus, the total access time for serving these requests is thus Ei=1" |r; - ri-Jl. One way to make disk drives faster is to have more heads and assume the second head starts at position n (the first head starts at 1 as before). Deciding which head should take which request is important for making the reads as fast as possible. After a head moves to serve a request, it stays at that location until it is needed to serve another request. For example: with n=10 and requests r = (1,5,1) compare two algorithms: "closest head serves request": for this algorithm the first head serves all requests: clearly the first head serves the first request and remains at position 1. for the second request, the first head is at distance (1-5) = 4 and the second head is at distance (10-5| = 5; thus, the first head is closer and it serves this request too, with an access time of 4. For the last request, clearly the first head is closer (it is currently at position 5) and it has an access time of 4 to move back to position 1. The total time is 4+4 = 8. "optimal": the first head serves request 1 and 3, the second head serves request 2. The access time is 0 for the first head (it never moves) and 15-10| = 5 for the second head (it moves only to serve request 2 at position 5) for a total of 5. Use dynamic programming to determine which head should serve each request to minimize the total access time

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions