Complexity of Nested for Loops
<p>I'm trying to figure out the time of my algorithm, using Big O notation, and I couldn't find a quite clear explanation about it.</p>

<p>Basically, my algorithm consists in comparing a new array to all other arrays in a "parent" array. </p>

<p>For that, I have a for loop, that iterates all elements in the parent array, looking for an array that looks like the newly created array. </p>

<p>Here's the code:</p>

<pre><code>bool AlreadyExistingArray(Array array)
{
    bool areEqual = true;
    foreach (Array a in arrayEntries)
    {
        if (a.count != array.count)
            continue;

        foreach (int i in array)
        {
            if (!a.contains(i))
            {
                areEqual = false;
                break;
            }
        }
        if (areEqual)
        {
            areEqual = false;
            foreach (int i in a)
            {
                if (!a.contains(i))
                {
                    areEqual = false;
                    break;
                }
            }
        }
    }
    return areEqual;
}
</code></pre>

<p>I understand that each of the for loops should be a O(n), however, should the complexity be composed? Since I'm dealing with different sized arrays, I'm quite sure the complexity cannot be considered O(n^2).</p>

<p>Hope I made myself clear! Otherwise, let me know and I'll try and clarify even further.</p>

<p>Edit: changed algorithm.</p>