Use the binary heap to return the k elements from largest to smallest | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Use the binary heap to return the k elements from largest to smallest

I did code below. I started to build the maxHeap first and then removeMax. After that i stored it into an array from root, which is the largest element to smallest then I returned the k elements largest. However, it said the error from line "Word result = wordArray[0];" in removeMax() method. Could someone help me to fix it? https://code.sololearn.com/cqU80EohWkt0/#java

3rd Nov 2018, 7:48 PM
Tuyen Pham
Tuyen Pham - avatar
2 Answers
0
Tuyen Pham Check your link, its not a valod code link
3rd Nov 2018, 11:00 PM
KrOW
KrOW - avatar
0
i fixed this @KrOW
3rd Nov 2018, 11:02 PM
Tuyen Pham
Tuyen Pham - avatar