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
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() Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
