Ab Initio Interview Question

You are modelling a spreadsheet software like excel. Cells can have dependencies. Give a data structure and algorithm for detecting dependencies between cells in a spreadsheet. Where can this go wrong? (Cycle) give an algorithm for detecting this. Time complexity of both.