I need help with my code Heap Sort JavaScript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I need help with my code Heap Sort JavaScript

Something is wrong with the computation, seems It prints out the first number in the array the amount of integers in the arry. And how would I make it for user input via text box not alert https://code.sololearn.com/W8wmrIRuZfi3/?ref=app

13th Sep 2019, 9:43 PM
Leonardo Monterey
Leonardo Monterey - avatar
4 Answers
+ 1
I believe the only problem is that the swap function needs a slight adjustment. Change line 45 from input[index_A]= input[index_B]= temp; To input[index_A]= input[index_B]; input[index_B]= temp;
15th Sep 2019, 11:18 AM
Brian
Brian - avatar
+ 1
It worked😛 Alright, thanks a bunch
15th Sep 2019, 3:45 PM
Leonardo Monterey
Leonardo Monterey - avatar
+ 1
You're welcome!
15th Sep 2019, 5:40 PM
Brian
Brian - avatar
0
Thank You, I will look that up.
15th Sep 2019, 3:40 PM
Leonardo Monterey
Leonardo Monterey - avatar