Question
1. a) In a priority queue (not necessarily a min-heap) with n > 0 nodes, how many are leaves? Write one mathematical formula (not a
1. a) In a priority queue (not necessarily a min-heap) with n > 0 nodes, how many are leaves? Write one mathematical formula (not a C0 expression) that expresses the number of leaves regardless of whether n is even or odd. You may use ?x? to round x down and ?x? to round x up.
b) Suppose a sequence of n elements are inserted into a priority queue so that the priority of each element inserted is strictly decreasing. Afterward, the elements are removed one at a time based on priority. What common data structure does this priority queue implement?
c) If the priorities are strictly increasing instead, what common data structure does this priority queue implement?
d) Consider a non-empty priority queue of n elements, each with a di erent priority. This priority queue is represented using the array implementation of min-heaps. Give the exact range (inclusive), in terms of n, of array indexes where any element of lowest priority might occur. You may use mathematical notation or C0 notation.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started