Реализовать PriorityQueue с помощью BinarySearchTree: Java

Мне нужно «создать очередь приоритетов, реализованную двоичным деревом поиска (BST)» для моих алгоритмов II класса. Однако я не совсем уверен, как использовать двоичное дерево поиска в качестве очереди с приоритетами. Может кто-нибудь прояснить, что меня просят сделать задание?

В качестве справки: вот методы, которые должен реализовать PriorityQueue:

add – adds a new item to the queue
peek – returns the head of the queue
remove – removes the head of the queue and returns it
search – returns the position of an element in the queue, or -1 if it is not found.
size – returns the total number of elements in the queue
inorder – returns an in-order, comma-separated string of every element in the queue
preorder – returns an pre-order, comma-separated string of every element in the queue
height – returns the height of the underlying BST

Заранее благодарю вас за любой совет !!

5
задан Bill the Lizard 18 December 2012 в 15:34
поделиться