Create and implement a data structure that provides the following operations:
- insert
- delete
- find min
- find max
- delete min
- delete max
- insert
- delete
- find min
- find max
- delete min
- delete max
❤7
Some possible solution for the problem posted above:
balanced binary search tree will provide us with all of these operations in O(log n). If some operations are more frequent, e.g. find max, min, we can use min and max heaps to make these operations in O(1). All elements are stored in linked list and heaps store pointers to nodes, so we can remove min and max in O(1) as well. Unfortunately, delete will take O(n). Please take a look at the following links for more ideas and discussion: http://www.geeksforgeeks.org/a-data-structure-question/
balanced binary search tree will provide us with all of these operations in O(log n). If some operations are more frequent, e.g. find max, min, we can use min and max heaps to make these operations in O(1). All elements are stored in linked list and heaps store pointers to nodes, so we can remove min and max in O(1) as well. Unfortunately, delete will take O(n). Please take a look at the following links for more ideas and discussion: http://www.geeksforgeeks.org/a-data-structure-question/
GeeksforGeeks
Design an efficient data structure for given operations - GeeksforGeeks
Your All-in-One Learning Portal: GeeksforGeeks is a comprehensive educational platform that empowers learners across domains-spanning computer science and programming, school education, upskilling, commerce, software tools, competitive exams, and more.
👍4❤2