This is an old revision of the document!
Highschool workshop - Introduction to D
Exercises
Compute the median element of an unsorted integer array. For this, you will have to:
Sort the array: implement any
sorting algorithm you wish. At this
link you will find a series of searching algorithms, each implemented in its own C file.
Eliminate the duplicates: once the array is sorted, eliminating the duplicates is trivial. The array operations discussed, and more, can be found at
this reference.
Select the (n+1)/2th element.
Write
unittests to validate your implementation.
Use small
functions to increase code readability and testing.