// see DbFile.java for javadocs
  public ArrayList<Page> insertTuple(TransactionId tid, Tuple t)
      throws DbException, IOException, TransactionAbortedException {
    // some code goes here
    BufferPool bp = Database.getBufferPool();
    int id = getId(), i, slots;
    ArrayList<Page> retlist = new ArrayList<Page>();
    PageId pid = null;
    HeapPage p = null;
    for (i = 0; i < numPages(); i++) {
      pid = new HeapPageId(id, i);
      p = (HeapPage) bp.getPage(tid, pid, Permissions.READ_WRITE);
      slots = p.getNumEmptySlots();
      if (slots > 0) {
        p.insertTuple(t);
        retlist.add(p);
        return retlist;
      }
    }

    // create new page and add tuple to it
    pid = new HeapPageId(id, i);
    raf.setLength(raf.length() + BufferPool.PAGE_SIZE);
    p = (HeapPage) bp.getPage(tid, pid, Permissions.READ_WRITE);
    p.insertTuple(t);
    retlist.add(p);
    return retlist;
  }
 // see DbFile.java for javadocs
 public Page deleteTuple(TransactionId tid, Tuple t)
     throws DbException, TransactionAbortedException {
   // some code goes here
   BufferPool bp = Database.getBufferPool();
   RecordId rid = t.getRecordId();
   if (rid == null) {
     throw new DbException("Tuple is not a member of this file");
   }
   HeapPage p = (HeapPage) bp.getPage(tid, rid.getPageId(), Permissions.READ_WRITE);
   p.deleteTuple(t);
   return p;
 }