duplicate detection algorithm

This is a discussion on duplicate detection algorithm within the C Programming forums, part of the General Programming Boards category; Hi.
I've been having troubles with a permutation program. I'm using a module named 'duplicate()' wich tells me when an ...

duplicate detection algorithm

I've been having troubles with a permutation program. I'm using a module named 'duplicate()' wich tells me when an array of int named 'A' has a duplicate. That is>

A[1] = 5, A[2] = 3, A[3] = 1 A[4] = 5.

there is a duplicate here, A[1] = 5 and A[4] = 5

the function works when the dimension of A is small, say 5 or 6. When the dimension is about 15, the function fails and the program blacks out-

The module is recursive and it works as follows

it takes the first element of A (A[1]) and compares it with the following elements to the right (A[2], A[3] etc. if there is a duplicate, the function returns 1. Otherwise it calls itself, but now taking as first element the element at the right, A[2]. and so on.

The first call from the main program would be duplicate(1)

I'm posting the following code of 'duplicate()'. OBJECTS is the dimension of A[]

If you want to be happy one hour: take a nap
if you want to be happy one day: go fishing
If you want to be happy a year: inherit a fortune
if you want to be happy for a life time: HELP SOMEBODY
chinisse say.

You're confused. Return statements within loops don't cause stack overflows! Recursion can often cause them, but usually only when large arrays are declared recursively, for example. I don't know what a 'permutation' is. Care to explain a little more about it?

If you want to be happy one hour: take a nap
if you want to be happy one day: go fishing
If you want to be happy a year: inherit a fortune
if you want to be happy for a life time: HELP SOMEBODY
chinisse say.