/* ------------------------------------------------------------------- * FUNCTION: Delete * * Deletes the substring between indexes i-j. * * Time Complexity: O(logN) * ------------------------------------------------------------------- */ public void Delete(int i, int j) { if (i < 0 || j < 0 || i > j) // if indices are invalid, return { return; } Rope R2; if (j >= TotalLength) // cut off end of rope { R2 = Split(i); } else { R2 = Split(i); // split at i R2 = R2.Split(j - i + 1); // split at j Concatenate(R2); // piece remains together } }