Given the MinHeap class discussed in section 17.6, select the statement(s) needed to complete the following method, which displays the n smallest values in the parameter array. public static void nSmallestValues(Comparable[] array, int n)
{
MinHeap h = new MinHeap() ;
For(Comparable value : array)
{
h.add(value) ;
}
System.out.print(n + " smallest value(s) : ") ;
For(int i = 0; i < n; ++i)
{
___________________________
}
}
A) System.out.println(h.remove() ) ;
B) System.out.println(h.peek() ) ;
C) System.out.println(array[i]) ;
D) System.out.println(h.elements.get(i) ) ;
Correct Answer:
Verified
Q97: Which of the following statements about a
Q97: If the postorder traversal of an expression
Q98: If the postorder traversal of an expression
Q99: What are the differences between preorder, postorder,
Q101: If a min-heap has 1024 nodes, what
Q103: What is the complexity of adding an
Q104: Which action(s) will invalidate a min-heap so
Q105: What is the complexity of removing an
Q106: What is the efficiency of the heapsort
Q107: When we map a min-heap with n
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents