wiz-icon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

Which of the following data structure is efficient to implement priority queue with basic operation such as insertion, deletion and searching ?

A
Sorted array
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
B
Linked list
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
Heap
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
Unsorted array
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution

The correct option is A Sorted array
Priority queue:
1. Via linked list : Insertion = O(n) , Deletion =O(1), Search = O(n)
2. Via Sorted array : Insertion = O(n) , Deletion = O(1) , Search =O(logn)
3. Via Unsorted array : Insertion =O(1) , Deletion = O(n), Search =O(n)
4. Via Heap list : Insertion =O(logn), Deletion = O(logn), Search = O(n)

flag
Suggest Corrections
thumbs-up
0
similar_icon
Similar questions
View More
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Venn Diagrams
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon