St Cloud State University Animal Shelter Data Structure Python Program
Question Description
I’m working on a Python question and need a sample draft to help me study.
An animal shelter holds only dogs and cats, and operates on a strictly “first in, first out” basis. People must adopt either the “oldest” (based on arrival time) of all animals at the shelter, or they can select whether they would prefer a dog or a cat (and will receive the oldest animal of that type). They cannot select which specific animal they would like. Create the data structures to maintain this system and implement operations such as enqueue, dequeueAny, dequeueDog and dequeueCat. Assume each animal has an unique name and thus you don’t need to worry. You need to use at most O(n) storage and O(1) for all operations, where n is the total number of animals in the shelter. Your program should read test files t80.dat and t81.dat in the same directory as your p8.py or p8.ipynb, and generate output for both t80 and t81 as the example below. You need handle whitespace as the whitespace convention and handle errors.
Example Input and Output (as comments below) in chronological order:
enqueue(dog, Bark) # put the dog named Bark to shelter
enqueue(cat, Mimi) # put the cat named Mimi to shelter
enqueue(cat, Tiger) # put the cat named Tiger to shelter
dequeue(cat) # the cat named Mimi is adopted
dequeueAny() # the dog named Bark is adopted
dequeue(dog) # no dog left to be adopted
t81
enqueue(dog, Bark) # put the dog named Bark to shelter
enqueue(cat, Mimi) # put the cat named Bark to shelter
enqueue(cat,Tiger) # put the cat named Bark to shelter
dequeue(cat) # the cat named Mimi is adapte
denqueue(cat,Lion) # put the cat named Bark to shelter
dequeueAny() # the dog named Bark is adapted
dequeue(dog) # no dog left to be adapted
t80
enqueue(dog,Bark)
enqueue(cat,Mimi)
enqueue(cat,Tiger)
dequeue(cat)
dequeueAny()
dequeue(dog)
Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."