Structured Data Types and Encapsulation Mechanisms to create new data types: –Structured data Homogeneous: arrays, lists, sets, Non-homogeneous: records.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Pointers.
Chapter 12 File Management Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
Arrays and records Programming Language Design and Implementation
Programming Languages and Paradigms
Names and Bindings.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Subprogram Control - Data sharing Mechanisms to exchange data Arguments - data objects sent to a subprogram to be processed. Obtained through  parameters.
Chapter 7:: Data Types Programming Language Pragmatics
Elementary Data Types Prof. Alamdeep Singh. Scalar Data Types Scalar data types represent a single object, i.e. only one value can be derived. In general,
Chapter Four Data Types Pratt 2 Data Objects A run-time grouping of one or more pieces of data in a virtual machine a container for data it can be –system.
File Management Chapter 12. File Management A file is a named entity used to save results from a program or provide data to a program. Access control.
Lecture # 02 07/02/2013Dr. Muhammad Umair 1. 07/02/2013Dr. Muhammad Umair 2  Numeric  Integer Numbers  0,10,15,4563 etc.  Fractional Number  10.5,
Chapter 6 Structured Data Types Arrays Records. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Definitions data type –collection of data objects.
1 Problem Solving Abstraction Oftentimes, different real-world problems can be modeled using the same underlying idea Examples: Runtime storage, Undo operation.
Fall 2004 ECE569 Lecture ECE 569 Database System Engineering Fall 2004 Yanyong Zhang Course.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
ISBN Chapter 6 Data Types: Structured types.
G. Levine Chapter 6 Chapter 6 Encapsulation –Why do we want encapsulation? Programmer friendliness- programmer need not know about these details –Easier.
Chapter 10 Storage Management Implementation details beyond programmer’s control Storage/CPU time trade-off Binding times to storage.
The environment of the computation Declarations introduce names that denote entities. At execution-time, entities are bound to values or to locations:
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
1 Friday, July 07, 2006 “Vision without action is a daydream, Action without a vision is a nightmare.” - Japanese Proverb.
Elementary Data Types Scalar Data Types Numerical Data Types Other
Chapter 9: Subprogram Control
File Management.
Chapter 6 Structured Data Types Arrays Records. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Definitions data type –collection of data objects.
MT311 Java Application Programming and Programming Languages Li Tak Sing ( 李德成 )
1 Chapter 5: Names, Bindings and Scopes Lionel Williams Jr. and Victoria Yan CSci 210, Advanced Software Paradigms September 26, 2010.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Data Structures Winter What is a Data Structure? A data structure is a method of organizing data. The study of data structures is particularly important.
Names Variables Type Checking Strong Typing Type Compatibility 1.
5-1 Chapter 5: Names, Bindings, Type Checking, and Scopes Variables The Concept of Binding Type Checking Strong Typing Type Compatibility Scope and Lifetime.
Arrays. Arrays as ADTs An array is an Abstract Data Type –The array type has a set of values The values are all the possible arrays –The array type has.
ARRAYS 1 Week 2. Data Structures  Data structure  A particular way of storing and organising data in a computer so that it can be used efficiently 
1 © 2002, Cisco Systems, Inc. All rights reserved. Arrays Chapter 7.
Lec 6 Data types. Variable: Its data object that is defined and named by the programmer explicitly in a program. Data Types: It’s a class of Dos together.
Data Structure & File Systems Hun Myoung Park, Ph.D., Public Management and Policy Analysis Program Graduate School of International Relations International.
Pointers. The structure of memory Computer memory is a linear sequence of addressable locations Addresses are numbered starting at zero In personal computers,
Introduction A variable can be characterized by a collection of properties, or attributes, the most important of which is type, a fundamental concept in.
Basic Semantics Associating meaning with language entities.
ISBN 0-321— Chapter 6 Structured Data Types Arrays Associated Arrays Records Unions.
1 File Management Chapter File Management n File management system consists of system utility programs that run as privileged applications n Concerned.
1 Records Record aggregate of data elements –Possibly heterogeneous –Elements/slots are identified by names –Elements in same fixed order in all records.
Understanding Data Types and Collections Lesson 2.
ISBN Chapter 6 Structured Data Types Array Types Associative Arrays Record Types Union Types.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Engineering Computing I Chapter 5 Pointers and Arrays.
REEM ALMOTIRI Information Technology Department Majmaah University.
Arrays. Arrays as ADTs An array is an Abstract Data Type –The array type has a set of values The values are all the possible arrays –The array type has.
Operating Systems Files, Directory and File Systems Operating Systems Files, Directory and File Systems.
1 ENERGY 211 / CME 211 Lecture 4 September 29, 2008.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 330 Programming Language Structures Operational Semantics (Slides mainly.
W4118 Operating Systems Instructor: Junfeng Yang.
Chapter 9: Data types and data structures OCR Computing for A Level © Hodder Education 2009.
CSI 3125, Data Types, page 1 Data types Outline Primitive data types Structured data types Strings Enumerated types Arrays Records Pointers Reading assignment.
Data Types In Text: Chapter 6.
File-System Implementation
Abstract Data Types and Encapsulation Concepts
Type Checking Generalizes the concept of operands and operators to include subprograms and assignments Type checking is the activity of ensuring that the.
Type Checking, and Scopes
Implementing Subprograms
Activation records Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Introduction to Data Structure
Arrays and records Programming Language Design and Implementation
Arrays and records Programming Language Design and Implementation
Arrays and records Programming Language Design and Implementation
Arrays and records Programming Language Design and Implementation
Activation records Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Presentation transcript:

Structured Data Types and Encapsulation Mechanisms to create new data types: –Structured data Homogeneous: arrays, lists, sets, Non-homogeneous: records –Subprograms –Type declarations – to define new types and operations (Abstract data types) –Inheritance

Structured data types A data structure is a data object that contains other data objects as its elements or components.

Data specifications  Number of components and size  Type of each component  Selection mechanism  Maximum number of components  Organization of the components

Data specifications  Number of components and size Fixed size - Arrays Variable size – stacks, lists. Pointer is used to link components.  Type of each component Homogeneous – all components are the same type Heterogeneous – components are of different types

Data specifications - selection Selection mechanism to identify components – index, pointer Two-step process: referencing the structure selection of a particular component

Data specifications - organization  Simple linear sequence - arrays, stacks, lists  Multidimensional structures:  separate types (Fortran)  a vector of vectors (C++)

Operations on data structures  Component selection operations Sequential Random Insertion/deletion of components  Whole-data structure operations Creation/destruction of data structures

Implementation of structured data types Storage representations Implementation of operations on data structures Storage management

Storage representation storage for the components optional descriptor, contains some or all of the attributes Sequential representation Linked representation INCLUDES:

Sequential representation the data structure is stored in a single contiguous block of storage, that includes both descriptor and components. Used for fixed-size structures, homogeneous structures (arrays, character strings)

Linked representation the data structure is stored in several noncontiguous blocks of storage, linked together through pointers. Used for variable-size structured (trees, lists) Flexible, ensures true variable size, however it has to be software simulated

Implementation of operations on data structures Component selection in sequential representation Base address plus offset calculation. Add component size to current location to move to next component. Component selection in linked representation Move from address location to address location following the chain of pointers.

Storage management Access paths to a structured data object - to endure access to the object for its processing. Created using a name or a pointer. Two central problems: Garbage – data object is bound but access path is destroyed. Memory cannot be unbound. Dangling references: the data object is destroyed, but the access path still exists.

Declarations and type checking for data structures What is to be checked: Existence of a selected component Type of a selected component

Vectors and arrays Vector - one dimensional array Matrix - two dimensional array Multidimensional arrays Slice - a substructure in an array that is also an array, e.g. a column in a matrix Associative Arrays - elements are selected by a key value

Implementation of array operations Access - can be implemented efficiently if the length of the components of the array is known at compilation time. The address of each selected element can be computed using an arithmetic expression. Whole array operations, e.g. copying an array - may require much memory.

Records A record is data structure composed of a fixed number of components of different types. The components may be heterogeneous, and they are named with symbolic names.

Other structured data objects Records and arrays with structured components Lists and sets Executable data objects Data structures are considered to be a special type of program statements and all are treated in the same way (Prolog).

Abstract Data Types An abstract data type is: A set of data objects, A set of abstract operations on those data objects Encapsulation of the whole in such a way that the user of the data object cannot manipulate data objects of the type except by the use of operation defined.

Information Hiding When information is encapsulated in an abstraction, it means that the user of the abstraction 1. Does not need to know the hidden information in order to use the abstraction 2. Is not permitted to directly use or manipulate the hidden information even if desiring to do so.

Mechanisms that support encapsulation Subprograms Type definitions