Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started