Can a trasaction be rolled back if a table is edited outside a transaction? I am learning how transactions work using this short script

CREATE TABLE t_test (id INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;

START TRANSACTION;

INSERT
INTO    t_test
VALUES  (1);

SELECT  *
FROM    t_test;

 id
---
  1

SAVEPOINT tran2;

INSERT
INTO    t_test
VALUES  (2);

SELECT  *
FROM    t_test;

 id
---
  1
  2

ROLLBACK TO tran2;

SELECT  *
FROM    t_test;

 id
---
  1

ROLLBACK;

SELECT  *
FROM    t_test;

 id
---


Towards the end,ROLLBACK a savepoint is used.Does it mean when ROLLBACK is used it wipes out everything that was commited earlier on?.

Secondly,what if i edit the table outside of the transaction and the try ROLLBACK TO trans2 for instance,what happens?.
A SAVEPOINT is not a commit.  It doesn't "save" anything other than the "point" where you are, in the transaction, when you create it... allowing you to roll back to the savepoint, if you need to, without rolling back the entire transaction.

You can't alter a table in another connection while one or more transactions is holding locks against it -- the other connection will be forced to wait for the table metadata lock.  You also can't modify the rows, gaps, or indexes locked by one transaction from within another connection... so either way you try to "edit" the table from outside the transaction, the second requester will have to wait.

This is where deadlocks come in to play. In oversimplified terms... If I do something in a transaction, then you do something in a transaction, then I try to do something that requires me to wait on a lock held by your transaction, then you try to do something that requires you to wait for a lock held by my transaction, we are in a deadlock condition, where we would both literally wait forever, since neither of us can proceed without the lock held by the other.  InnoDB will detect this and force one or the other of us to forfeit our transaction by throwing a deadlock exception.  The "winner" will proceed unaffected, not knowing anything happened to the "loser."