LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Quicksort algorithm's incomplete implementation in book, in the C language. (https://www.linuxquestions.org/questions/programming-9/quicksort-algorithms-incomplete-implementation-in-book-in-the-c-language-4175726130/)

Guttorm 06-20-2023 04:37 AM

Also, qsort has a friend called bsearch.

If you look at the example here:

https://man7.org/linux/man-pages/man3/bsearch.3.html

First the array is sorted by name. Then bsearch is used for lookup. If the array had millions, using bsearch is a lot faster, because it doesn't have to search through the entire array. And the comparison function is the same.

NevemTeve 06-21-2023 01:58 AM

Off: for learners, it would be an interesting exercise to find the missing features in bsearch(3)
For example the lack of user-parameter in callback (compare qsort(3) and qsort_r(3))


All times are GMT -5. The time now is 10:03 AM.