Solved

Given the MinHeap Class Discussed in Section 17

Question 102

Multiple Choice

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:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents