Skip to content
All tags

#function-pointers

2 posts

Stanford CS107 Lecture 13: From Comparators to a Fully Generic Bubble Sort

CS107 Lecture 13 upgrades a Boolean callback to a three-way comparator, then combines void *, element width, and const void * callbacks into a fully generic bubble sort before mapping the design to qsort, bsearch, lfind, and lsearch.

Stanford CS107 Lecture 12: Function Pointers Inject Ordering into Generic C

CS107 Lecture 12 first uses char * for byte-wise generic swap and rotate, then uses a function pointer to separate bubble sort's traversal mechanism from its ordering rule: void * abstracts data types, while callbacks abstract behavior.