Qsort is another term for Quicksort. Quicksort is one of the best known of the fast, recursive algorithms. Also, the standard C library includes Qsort in stdlib.h iirc.
As I understand your requirements however, you do not need Quicksort/Qsort, at all.
Welcome to Bucketsort! It's usually not recursive, but can be written that way. This is the non-recursive (iterative) Bucketsort.
Code:
int Bucketsort(const int a[], int n, int bucket[20]) {
int i;
for(i = 0; i < n; i++) {
if(a[i] > 0)
bucket[ a[i] ]++;
}
So if a[0] = 5, then bucket[5] is incremented by one. That is, bucket has a list in it's elements, of how many of each number, is found in a[].
a[] = {1,2,3, 2}
bucket[] == {0, 1, 2, 1} (There are no zero's, there is one 1, there are two 2's, and one 3).
This solves your stated problem, except it's not recursive. Now, can you take out the for line, and give it a "base case", so it will not loop forever, and make it call itself?
Give that a try. You will need to do this for both your arrays (so maybe bucketa[] and bucketb[]). That is, you'll need to bucketsort, both of your int arrays.
Then recursively walk thru the two bucket arrays. Any element number greater than zero, in both arrays, is an intersecting number.
Code:
int check(int bucketa[], int bucketb[], int n, int i) {
if(++i >= n)
return;
if(bucketa[i] > 0 && bucketb[i] > 0)
printf(" %d,", i);
check(int bucketa[], int bucketb[], int n, int i);
}
The above is not tested, and is more for a springboard for your code, not working code.