+ 1

CALLING ALL C MASTERS!!!

Hey there guys! Im having some trouble with this C code im writing. I was trying to implement my favorite sorting algorithm. So I have fiddled with it for a while and it looks like the HeapSort function is never getting hit. It makes me think im somehow the recursion in the maxHeapify function is broken. Im not sure if this is an issue with the logic or some technique to recursion in c. https://code.sololearn.com/c1FtKAJ07Y8T

27th Jun 2018, 2:41 AM
Haon1919
Haon1919 - avatar
5 ответов
+ 1
hey, your code seems to be unnecessarily complicated, here's a simpler way to do it: https://code.sololearn.com/crNANNRDaKAF/?ref=app
27th Jun 2018, 9:15 AM
hinanawi
hinanawi - avatar
+ 1
@hinanawi yaaaa I just wanted to get experience taking user input and messing around with pointers. It turns out one of the problems I was having was because the logic for my Left and Right function was messed up. I made some changes and now it looks like I am reading the data in wrong somehow because some of the indexes of the array appear to contain garbage. Could you check it out one more time? https://code.sololearn.com/c1FtKAJ07Y8T
27th Jun 2018, 7:16 PM
Haon1919
Haon1919 - avatar
+ 1
@hinanawi sorry about that! ill clean uo the output real quick to better illestrate what is going on
27th Jun 2018, 7:57 PM
Haon1919
Haon1919 - avatar
2nd Jul 2018, 12:55 PM
Haon1919
Haon1919 - avatar
0
Haon1919 your code output is not the most readable, can't quite tell what's going on
27th Jun 2018, 7:45 PM
hinanawi
hinanawi - avatar