Practice ยท 1 of 2
Sort & Search Through stdlib
Use qsort and bsearch โ no hand-rolled sorts. Implement:
``c
/* sorts n ints ascending */
void sort_ints(int *a, size_t n);
/* returns index of ANY occurrence of key in the SORTED array via
bsearch; -1 if absent. Precondition: a is sorted ascending. */
long find_int(const int *a, size_t n, int key);
/* sorts n doubles ascending (careful: doubles need a different cmp) */
void sort_doubles(double *d, size_t n);
``
The boilerplate provides both comparators; you wire qsort/bsearch.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: qsort, bsearch & _Generic Gym