This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: IE 170 Final Examination Practice Problems Dr. T.K. Ralphs 1. (from David Eppstein, UC Irvine) Suppose you are implementing a spreadsheet program in which you must maintain a grid of cells. Some cells contain values, while other cells contain formulas that depend on other values. After the user enters a new formula into a given cell or updates an already-existing formula, the spreadsheet program must first determine whether there are any circular dependencies , meaning a sequence of calculations that all depend on each other in a circular fashion. For example, if the expression in cell E1 depends on the value in cell C5 and the expression in cell C5 depends on the value in cell D3, then the expression in cell D3 is not allowed to depend on the value in cell E1. If a circular dependency exists, then the program must notify the user of the error and prompt for a correction. After it has been determined that there are no more circular dependencies, the program must then recalculate the values in the spreadsheet. In order to do this, the program must determine (1) which values may have changed and (2) in what order the changed values need to be recalculated. Implementing the spreadsheet requires a data structure for storing the spreadsheet in memory and one for storing the dependencies. In addition, we might have a separate file format for storing the spreadsheet on disk when not in use. The data structure for the spreadsheet itself is used to store the contents of each cell, including the formula for computing the value in the cell (if there is one) and the value itself. The data structure for the dependencies is used to look for circular dependencies and determine the order of calculation during an update. (Actually, there is a way to link these two data structures into one, but we will consider them separately). (a) Describe two alternative data structures for storing the spreadsheet in memory while it is being edited and discuss the advantages and disadvantages of each. Hint: Consider the time-space tradeoff. For each data structure, consider both the time required to look up the contents of a cell and the space required to store the spreadsheet. (b) Suppose the spreadsheet user is editing a particular cell. State an algorithm that either (1) determines all cells that must be recalculated after a change to the cell being edited or (2) detects a circular dependency. Determine the running time of the algorithm. Hint: You may want to construct a graph. If so, please state explicitly how the graph is constructed. (c) Assuming no circular dependencies exist, state an algorithm for determining the order in which the cell values should be recalculated and analyze its running time....
View Full Document
This note was uploaded on 02/29/2008 for the course IE 170 taught by Professor Ralphs during the Spring '07 term at Lehigh University .
- Spring '07