- Learn to use function addresses
- Learn to use the
- Gain some perspective on different sorting algorithms.
This homework is about sorting.
For the more practical approach, you will also write a wrapper function for the standard
qsort(…) function, an implementation of the
There is one starter file: sorts.h. To get it, run
Outline of a solution
👌 Okay to copy/adapt anything you see in these two screenshot images. (You may not copy code from lecture or anywhere else.)
Before quick_sort_array(array2) 5 4 2 1 7 6 3 After quick_sort_array(array2) 1 2 3 4 5 6 7
- Your submission must contain each of the following files, as specified:
- This should simply call the
qsort(…)function requires the use of function addresses (function pointers).
- This may not result in any heap allocation (i.e., calls to
malloc(…)) by your code.
- Yes, this is easy, but make sure you understand how it works!
- This must cause every line of code in your sorts.c to be executed.
- Every public function in sorts.c must be called directly from
main(…)and/or from a helper within test_sorts.c.
- Only the following externally defined functions and constants are allowed in your .c files. (You may put the corresponding #include <…> statements in the .c file or in your sorts.h, at your option.)
header functions/symbols allowed in… stdbool.h
- Submissions must meet the code quality standards and the policies on homework and academic integrity.
→ return type: voidSort
→ return type: intTest your functions in sorts.c.
To submit EC01 from within your ec01 directory,
264submit EC01 sorts.h sorts.c test_sorts.c expected.txt miniunit.h clog.h Makefile
The pre-tester for EC01 has not yet been released. As soon as it is ready, this note will be changed.
Can I add helper functions to sorts.c?
Yes. Make sure the names begin with "_". Also, they should be declared as static.
Is it a violation of the spec if
No. The only requirement is that your code not call
malloc(…)as a result of calling