Bifalgorithm post · Computer science one · Sorting

What are the advantages of using qsort() and related generic functions?

What are the advantages of using qsort() and related generic functions? (Computer science one · Sorting) — "The advantages to using qsort() (as well as lfind()…

Ideas in this flowchart

  • Advantages of using qsort(), lfind(), and bsearch()
  • The same library functions can support different user-defined structures and orderings.
  • There is no need to write a new sorting or searching function for every possible ordering.
  • The programmer only needs to create a comparator function and pass it to qsort().
  • Using these functions results in less code and fewer opportunities for bugs.
  • qsort() is well-designed, optimized, well-tested, and proven.
  • These functions provide a weak form of polymorphic behavior.
  • Polymorphism allows the same code to execute on different types, reducing duplicate code.
  • Their usage is illustrated in Code Samples 25.2 and …
Feed/

What are the advantages of using qsort() and related generic functions?

No cover

Channel

Computer science one

1 page

"The advantages to using qsort() (as well as lfind() and bsearch()) should be clear. There is no need to write a new function that reimplements the same algorithm for every possible ordering of every possible user-defined structure. We need only to create a comparator function and pass it to qsort(). There is less code, and less chance of bugs. The qsort() function is well-designed, optimized, and most importantly well-tested and proven. These functions represent a sort of “weak” form of polymorphic behavior found in more modern object-oriented programming languages and other languages that support “generic programming.” Polymorphism is the characteristic that the same code can be executed on different types, greatly reducing the need for duplicate code.\n\nWe illustrate the usage of these functions in Code Samples 25.2 and"

Flowchart preview
👍
0
0 comments0 shares

Sign in to view and post comments.