Ho bisogno di creare una coda di priorità implementato da un albero binario di ricerca (BST) per la mia classe di algoritmi II. Tuttavia, non sono sicuro esattamente come si usa un albero binario di ricerca come una coda di priorità. Qualcuno potrebbe chiarire che cosa è che l'assegnazione mi chiede di fare?
Come riferimento, qui sono i metodi che la CodaConPriorita deve implementare:
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
Grazie in anticipo per qualsiasi consiglio !!













