Coding / OOD + Data Structure
The interview used a simplified table:
rowName -> columnName -> value
I needed to implement:
createRow(String rowName)
deleteRow(String rowName)
updateCell(String rowName, String columnName, String newVal)
findAndReplace(String findString, String replaceString)
showTable()
beginTransaction()
commitTransaction()
rollbackTransaction()
The inputs for the basic operations were simply the parameters in each method signature. showTable() printed the current table. There were no especially complicated return-value requirements.
The table could be modified only after a transaction had begun.
The transaction behavior was similar to a database:
beginTransaction()starts a transaction.commitTransaction()saves the changes.rollbackTransaction()restores the state from beforebeginTransaction().
Rollback needed to handle create, delete, and update operations correctly. For example, a row created during the transaction had to be deleted after rollback, while an existing row had to be restored to its state before the transaction.
The problem did not require nested transactions or concurrent transactions. The focus was transaction state management and rollback.
Discussion
Loading comments…