[EPIJ v 1.6.1 Problem 14.4]
I’ve implemented an O(n log n) time solution that uses sorting and PriorityQueue. I’d like to know if a solution is possible without using PriorityQueue, while still maintaining the same time bound.
[EPIJ v 1.6.1 Problem 14.4]
I’ve implemented an O(n log n) time solution that uses sorting and PriorityQueue. I’d like to know if a solution is possible without using PriorityQueue, while still maintaining the same time bound.
Easier approach will be using BST as whatever priority queue can do, BST can do as well.
Follow up question - Is a solution possible without BST, PriorityQueue, or other such data structure?
whatever priority queue can do, BST can do as well
Not really, right? A priority queue can find min or max in O(1) time. A BST cannot. Am I missing something?