A back, we were given the task of writing a program c that sorts an array of n numbers using d-ary max-heap (a bunch where each node has up to d children). The program should ask the user to enter the value d, a value between 2 and the size of the array. While I was testing my program, I accidentally entered 1 as the value of d, and somehow the algorithm successfully sorted the array correctly using the 1-arch heap, although it took a lot more time than the normal values of d.
How is this possible? A 1-heap heap is not even a heap, it is just like a list, each node has only one child. Can someone explain how this sorting can happen?
source
share