Those of us lucky enough to have to develop our own sorting functions, either academically or professionally, have probably at least though about the efficiency the various algorithms. In fact, there's a whole science to this. But how many of us have taken a Bubble Sort (the least efficient of inefficient O(n2) sorts), brought it down a notch, like Andrew Reid colleague, and made it recursive?
void sortMe(ListType list) { for(int i = 0; i < (list.entries() - 1); i++) { if(list[i] > list[i+1]) { list.swap(i, i+1); sortMe(list); } } }
[Advertisement]
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!