{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# ch6 - Ch 6 Tables 6.1 Introduction lists sequence position...

This preview shows pages 1–7. Sign up to view the full content.

2001-2009 M. D. Evans All Rights Reserved 1 Ch. 6 Tables: 6.1 Introduction: lists vs tables sequence function position oriented wrt value (key-value) data items + opns oriented operations (next to) (look up) Def: A table with index set I and base type T is a function from I into T together with the opns: access – eval fn at any index I, rtn item insertion – of new element X to the index set. Define a corresponding value of the fn at X. deletion – delete X from I, and restrict fn to the resulting smaller domain.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2001-2009 M. D. Evans All Rights Reserved 2 Attributes: collection of elements in table size access function ??
2001-2009 M. D. Evans All Rights Reserved 3 Example: 1-dim array - subset of integers provides index set. - ordinal value of integer maps to a specific location in array. Note: 1. Array is a table; but in general case is the implementational tool for lists and tables as it possesses both sequencing & mapping characteristics. 2. ‘Positioning’ can be important in some tables. Athens Greece 2.1 * 10 6 London England 7 Rome Italy 2.9 Vancouver Canada 0.5 where the ‘look up’ operation is the key abstract operation, but is facilitated by the positioning.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2001-2009 M. D. Evans All Rights Reserved 4 Applications: mileage charts sports leagues’ statistics compiler design – symbol table (see Berman’s ch on tables)
2001-2009 M. D. Evans All Rights Reserved 5 6.2 Rectangular Tables: 6.2.1 Introduction: Def: An array is a collection of elements identified by an index set, a store opn that defines a mapping from the index set to the elements, and a retrieve opn that utilizes this mapping to obtain a stored element. Note: - an array is a data structure – nothing said about its impl n . - a programming tool available to build general tables. (analogous to linked lists building stacks!) We study: 1–dim arrays 2–dim arrays tables – special forms

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2001-2009 M. D. Evans All Rights Reserved 6 6.2.2 Implementation of 1-dim Arrays: array compiler mapping physical storage x[1] base x[2] base + 1 offset x[3] base + 2 offests when done ? – upon block activation Note: - compiler calculates relative addresses.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}