-2

Name a data structure that you could use to implement a queue such that all of the standard queue operations are O(1). If you are thinking of a data structure based on Python's built in list, you need to be more specific then just writing "list".

O(1) is constant time and I know that you can use lists to replace using ADTs but what does the question mean by being more specific? Also I thought that lists are O(n), linear time. How would I return something in constant time?

Note: I am a beginner comp sci student who is learning with Python

Raphael
  • 73,212
  • 30
  • 182
  • 400

1 Answers1

1

Have a look at this post here. Data structure with search, insert and delete in amortised time $O(1)$? To summarise, it is not possible to have all operations in constant time. If usage of parallelism is an option for you, have a look at this paper titled "A Parallel Priority Queue with Constant Time Operations", http://dx.doi.org/10.1006/jpdc.1998.1425.