Sedgewick Quick Union Analysis


I am currently studying Algorithms, Fourth Edition by Sedgewick et al. On page 226, there is an analysis of the quick union algorithm’s find() method’s worst case. This is the algorithm:

  private int p   {    while (p != id[p]) p = id[p];   return p;   } 

Now I count N comparisons in total (inside the while) plus N-1 accesses (last comparison is false) to rewrite the value of p. This would give me 2N – 1 accesses to the array. The textbook however says there are 2N+1 accesses. What am I doing wrong? Thanks for your time.