code: function(array, i, nodesToMove) {
      var length = array.length;
      var limit = i;
      var k = array.length - 2;
  
      while ((i >= nodesToMove) && ((array[i] % length) > limit)) {
        k = i;
        i -= (limit - i + 1);
      }
      i = Math.max (nodesToMove - 1, i);
  
      while (k > (i + 1)) {
        var temp = (i + k) >> 1;
        if ((array[temp] % length) > limit) {
          k = temp;
        } else {
          i = temp;
        }
      }
  
      return k;
    }
docs: FIRST() function
  @param array The code length array
  @param i The input position
  @param nodesToMove The number of internal nodes to be relocated
  @return The smallest {@code k} such that {@code nodesToMove <= k <= i} and
  {@code i <= (array[k] % array.length)}