Oracle interview implement a specific priority queue in python
Anonymous User
469
Jul 20, 2021
I got an interview from Oracle. I would like to share the question. The below is all the info of the question. Can anyone post your coding solution?
I did not finish all the functions by the time. Hope someone can show the code, so I can learn.Thanks
Can you implement a special priority queue class using python list with the following properties
and methods: (your should use ascending priority)
- Items in the queue can be flagged as fixed.
- Fixed items cannot be removed from the queue, and should stay in the queue
permanently - Provide the following methods:
- insert(item, permanent=False):
-add item into the queue in the proper position based on the priority
and flag the item to permanent if permanent==True
-if the queue is full, the new item replaces a non-permanent item with
the least priority - sample_items(n)
-select n items based on priority(n highest priority items), return a list
of selected items
-remove selected items from the queue if they are not flagged as
permanent - checkfull()
- should return True if the queue is full
Comments (0)


