In python I'm making a simulator program. I need to implement the Fifo , lru, Opt and
Fantastic news! We've Found the answer you've been seeking!
Question:
In python I'm making a simulator program. I need to implement the "Fifo" , "lru", "Opt" and "Rand" algorthims. This is what I have so far if you can help me finish these algorithms. def parse_input(): page_reference_string = input().split() num_frames = int(input()) algorithms = [] while True: try: algorithm = input().strip() algorithms.append(algorithm) except: break return page_reference_string, num_frames, algorithms def fifo(page_reference_string, num_frames): # Implement FIFO algorithm here pass def lru(page_reference_string, num_frames): # Implement LRU algorithm here pass def opt(page_reference_string, num_frames): # Implement OPT algorithm here pass def rand(page_reference_string, num_frames): # Implement RAND algorithm here pass def main(): page_reference_string, num_frames, algorithms = parse_input() print("Page Reference String:", " ".join(page_reference_string)) print("Number of Frames:", num_frames) for algorithm in algorithms: if algorithm == "FIFO": faults = fifo(page_reference_string, num_frames) elif algorithm == "LRU": faults = lru(page_reference_string, num_frames) elif algorithm == "OPT": faults = opt(page_reference_string, num_frames) elif algorithm == "RAND": faults = rand(page_reference_string, num_frames) print(algorithm + ":", faults) if __name__ == "__main__": main()
Related Book For
Understanding Financial Accounting
ISBN: 978-1118849385
1st Canadian Edition
Authors: Christopher Burnley, Robert Hoskin, Maureen Fizzell, Donald
Posted Date: