Question
Consider the following Java code snippet: Â Â
import java.util.ArrayList;   import java.util.Arrays;   import java.util.List;   import java.util.PriorityQueue;   public class HeapQuestion10 {     public static void main(String[] args) {       List numbers = Arrays.asList(7, 2, 9, 1, 5);       PriorityQueue pq = new PriorityQueue(numbers); // Initialize with a collection       System.out.println(pq.poll());       System.out.println(pq.poll());       System.out.println(pq.poll());     }   }   What will be the output of this program?Solution
When a PriorityQueue is initialized with a Collection (like numbers list here), it performs a "heapify" operation. This operation builds a min-heap (by default) from the given elements. The time complexity for building a heap from N elements is O(N).   1. List
What is the chemical formula of common salt?
The method of protecting iron from rusting, by coating a thin layer of Zinc is called -
Which among the following nutrients is essential for the normal functioning of the thyroid gland?
Tungsten is used for the construction of filament in an electric bulb because of itsÂ
A battery of emf 12 V and internal resistance 4 ohm is connected to a resistor. If the current in the circuit is 0.6 A, what is the resistance of the re...
A cylindrical metal wire is reformed so that its length decreases by 20% with no change of volume. Its
resistance decreases by:
Which of the following methods is suitable for preventing an iron frying pan from rusting?
What is the atomic number of carbon?
The Periodic Law stating that ‘the properties of elements are the periodic function of their atomic masses’ was given by
A mass m is suspended from a spring of spring constant k and oscillates with amplitude A. The maximum velocity during oscillation is: