I am trying to implement quicksort as a sorting algorithm. However, I seem to get an infinite loop. Tried my best to figure it out but couldn't. Any help appreciated. Here is the code.

Code:template <typename E> void TestQucikSort<E>::quickSort(E temparr [], size_t l, size_t r) const { if(r-l > 1) { E pivot = temparr[(l+r)/2]; size_t i = l, j = r; while(i <= j) { while(pivot > temparr[i]) ++i; while(temparr[j] > pivot) --j; if(i <= r) { std::swap(temparr[i],temparr[j]); ++i; --j; } } quickSort(temparr,l,j); quickSort(temparr,i,r); } }