This has been confusing me for sometime, not sure if someone can understand what I am trying to drive at
Source: https://www.oreilly.com/library/view/algorithms-in-a/9780596516246/ch04s06.html
I am trying to figure out what exactly does passing cmp as the argument into buildHeap does
buildHeap (ar, cmp, n);
the book appears to describe cmp as the comparator function (How does the compare function in qsort work?) and given that
static void buildHeap (void **ar, int(*cmp)(const void *,const void *), int n) {
Am i right to say that
int(*cmp)(const void *,const void *)
is essentially the C equivalent to a delegate in c#?
i.e. passing cmp into buildHeap teaches buildHeap on what function to implement, being the comparator function (which fits the signature of:)
int(*cmp)(const void *,const void *)
Would there be another way for me to teach buildHeap to do a comparator function without passing cmp?