Problem Statement: Write a program to implement optimal storage tape using greedy approach.
Objective- To find required order and Minimum
Retrieval Time.
Theory:
Greedy is an algorithmic paradigm that builds up a solution
piece by piece, always choosing the next piece that offers the most obvious and
immediate benefit.
Greedy algorithms try to find a localized optimum solution,
which may eventually lead to globally optimized solutions. However, generally
greedy algorithms do not provide globally optimized solutions.
Let’s suppose that the retrieval time of program i
is Ti. Therefore, Ti=∑i
j=1 Li
MRT is the average of all such Ti
is 1/n(∑n
i=1 Ti).
The sequential access of data in a tape has some
limitations. Order must be defined in which the data/programs in a tape are
stored so that least MRT can be obtained. Hence the order of storing becomes
very important to reduce the data retrieval/access time.
Time complexity for sorting is O(nlogn) if
std::sort() used. If you use bubble sort instead of std::sort(), it will
take O(n^2).
Comments
Post a Comment