bangusin mo ako/pusang basa

31
BANGUSIN MO AKO/PUSANG BASA ITANONGMOKAYKUYAJOBERT PRODUCTION DIRECTED BY: DARYLL “PTOYTOY” DARIA AND TIMOTHY “DAMASO” ARTIFICIO STARRING: JOENEL “PAPA J” DE ASIS, REINOEL “YU-TEN” RAGMAC, MEINARD “KAMAO” MORON

Upload: cutler

Post on 23-Feb-2016

63 views

Category:

Documents


0 download

DESCRIPTION

BANGUSIN MO AKO/PUSANG BASA. ITANONGMOKAYKUYAJOBERT PRODUCTION DIRECTED BY: DARYLL “PTOYTOY” DARIA AND TIMOTHY “DAMASO” ARTIFICIO STARRING: JOENEL “PAPA J” DE ASIS, REINOEL “YU-TEN” RAGMAC, MEINARD “KAMAO” MORON. PROGRAMMING LANGUAGE BSCS-2C Prof. Mina Villafuerte. Structured Data Types. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: BANGUSIN MO AKO/PUSANG BASA

BANGUSIN MO AKO/PUSANG BASA

ITANONGMOKAYKUYAJOBERT PRODUCTION

DIRECTED BY: DARYLL “PTOYTOY” DARIAAND TIMOTHY “DAMASO” ARTIFICIOSTARRING: JOENEL “PAPA J” DE ASIS,

REINOEL “YU-TEN” RAGMAC,MEINARD “KAMAO” MORON

Page 2: BANGUSIN MO AKO/PUSANG BASA

PROGRAMMING LANGUAGE

BSCS-2CProf. Mina Villafuerte

Page 3: BANGUSIN MO AKO/PUSANG BASA

Structured Data Types

Structured Data Objects and Data Types

-A data object that is constructed as an aggregate of other data objects, called components, is termed a structured data object or data structure. A component may be elementary or it may be another data structure(e.g., a component of an array me be a number or it may be a record, character string, or another array).

Page 4: BANGUSIN MO AKO/PUSANG BASA

Specification of Data Structure TypesThe major attributes for specifying data

structures include the ff. :

Number of components. A data structure may be of fixed size if the number if components is invariant during its lifetime or of variable size. Variable-sized data structure types usually define operations that insert and delete components from structures.

Arrays and records are common examples of fixed-size data structure types; stacks, lists, sets, tables and files are examples of variable-size types.

Page 5: BANGUSIN MO AKO/PUSANG BASA

Type of each components. A data structure is homogeneous if all its components are of the same type. It is heterogeneous if its components are of different types.

Ex. Arrays, sets and files are usually homogeneous, whereas records and lists are usually heterogeneous.

A data structure type need a selection mechanism for identifying individual components of the data structure.

Page 6: BANGUSIN MO AKO/PUSANG BASA

Maximum number of components. FOR A VARIABLE SIZE DATA STRUCTURES SUCH A STACKS.

Organization of the component.The most common organization is a simple linear sequence component. Multidimensional array, records whose components are records, and lists whose components are lists. These extended forms may treated as separate types or simply as the basic sequential type in which the components are data structures of similar type.The names to be used in components

Page 7: BANGUSIN MO AKO/PUSANG BASA

Operations on Data StructuresSpecification of the domain and range of operations

on data structure types may be given in much the same manner as for elementary types.

Some new classes of operations are of particular importance:

Component selection operations. Processing of data structures often proceeds by retrieving each component of the structure. Two types of selection operations access components of a data structure and make them available for processing by other

Page 8: BANGUSIN MO AKO/PUSANG BASA

operations: random selection, in which an arbitrary component of the data structure is accessed, and sequential selection, in which components are selected in a predetermined order.

Whole-data structure operations. Operations may take entire data structures as arguments and produce new data structures as results. Most languages provide limited set of such whole-data structure operations (e.g., addition of two arrays, assignment of one record to another, or a union operation on sets).

Page 9: BANGUSIN MO AKO/PUSANG BASA

Insertion/deletion of components.Operations that change the number of components in a data structure to have a major impact on storage representations and storage management for data structures.

Creation/destruction of data structures. Operations that create and destroy data structures also have a major impact on storage management for data structures.

Implementation of Data Structure TypesImplementation considerations for data structure

types include the same issues as for elementary types. In addition, two new issues develop that strongly affect the choice of storage

Page 10: BANGUSIN MO AKO/PUSANG BASA

representations : efficient selection of components from a data structure, and efficient overall storage management for the language implementation.

Storage Representations. The storage representation for a data structure includes (1) storage for the components of the structure, and(2) an optional descriptor that stores some or all of the attributes of the structure. The two basic representations are the ff. :

Page 11: BANGUSIN MO AKO/PUSANG BASA

Sequential Linked

Component

Component

Component

Component

Component Component

Component

Component

Component

Page 12: BANGUSIN MO AKO/PUSANG BASA

Sequential representation, in which the data structure is stored in a single contiguous block of storage that includes both descriptor and components.

Linked representation, in which the data structure is stored in several noncontiguous blocks of storage, with the blocks linked together through pointers.

Page 13: BANGUSIN MO AKO/PUSANG BASA

Implementation of Operations on Data Structures

Sequential representation. Random selection of a component often involves a base-address-plus-offset calculation using an accessing formula. The relative location of the entire block is the base address. The accessing formula, given the name or subscript of the desired component (e.g., the integer subscripts of an array component), specifies how to compute the offset of the component.

Page 14: BANGUSIN MO AKO/PUSANG BASA

Linked representation. Random selection of a component from a linked structure involves following a chain pointers from the first block of storage in the structure to the desired component. Selection of a sequence of components proceeds by selecting the first component and then following the link pointer from the current component to the next component for each subsequent selection.

Page 15: BANGUSIN MO AKO/PUSANG BASA

Storage Management and Data StructuresThe lifetime of any data objects begins when the binding of the object to a particular storage location is made (i.e., when a block [or blocks] of storage is allocated and the storage representation for the data object is initialized). The lifetime ends when the binding of object to storage block is dissolved.

At the time that a data object is created (i.e., at the start of its lifetime), an access path to the data must also be created so that the data object can be accessed by operations in the program.

Page 16: BANGUSIN MO AKO/PUSANG BASA

Creation of an access path is accomplished either through association of the data object with an identifier, its name, in some referencing environment or through storage of a pointer to the structure in some other exiting, already accessible structure.

During the lifetime of a data object, additional access paths to it may be created (i.e., by passing it as an argument to a subprogram or creating new pointers to it). Access paths may also be destroyed in various ways (e.g., by assigning a new value to a pointer variable or by return from a subprogram), with the consequent loss of its referencing environment.

Page 17: BANGUSIN MO AKO/PUSANG BASA

Accessing components ina C char array

A[0]

A[1]

A[5]

Base address =Location of A[0]

Base address + offset= lvalue(A[0]) + 5= lvalue(A[5])

Offset = i x component size= 5 x 1 = 5

Page 18: BANGUSIN MO AKO/PUSANG BASA

Two central problems in a storage management arise because of the interplay between the lifetime of a data object and the access paths to it that exist:1.) Garbage. When all access paths to a data object are destroyed but the data object continues to exist, the data object is said to be garbage. The data object can no longer be accessed from other parts of the program, so it is of no further use.2.) Dangling references. A dangling reference is an access path that continues to exist after the lifetime of the associated data object. An access path ordinarily lead to the location a data object (i.e., to the beginning of the block of storage for the object).

Page 19: BANGUSIN MO AKO/PUSANG BASA

Declaration and Type Checking for Data Structures

The basic concepts and concerns surrounding declarations and type checking for data structures are similar to those discussed for elementary data objects. However , structures are ordinarily more complex because there are more attributes to specify or component selection operations must be taken into account. These are two main problems:

Page 20: BANGUSIN MO AKO/PUSANG BASA

1.) Existence of a selected component. The arguments to a selection operation may be of the right types, but the component designated may not exist in the data structures.2.) Type of a selected component. A selection sequence may define a complex path through a data structure to the desired component.

Vector and ArraysA vector is a data structure composed of a fixed

number of components of the same type organized as a simple linear sequence.

Page 21: BANGUSIN MO AKO/PUSANG BASA

A component of a vector is selected by giving its subscript, an integer (or enumeration value) indicating the position of the components in the sequence. A vector is also termed a one-dimensional array or linear array. A two-dimensional array, or matrix , has its components organized into a rectangular grid of rows and columns. Both a row subscript and a column subscript are needed to select a component of a matrix. Multidimensional arrays of three or more dimensions are defined in a similar manner.

Page 22: BANGUSIN MO AKO/PUSANG BASA

Vector

LB

UB

Integer

Base Address of Vector

Storage representation

For components

Descriptor(dope vector)

E

Data type

Lower subscript bound

Upper subscript bound

Data type of component

Size of component

A[LB]

A[LB+1]

A[UB]

Page 23: BANGUSIN MO AKO/PUSANG BASA

39

42

45

483633

30

27

21

24

18

151 2 3

4 5 6

7 8 910 11 12

1 2 3

4 5 6

7 8 910 11 12

1 2 3

4 5 6

7 8 910 11 12

Column Slice Row Slice MultidimensionalSlice

Page 24: BANGUSIN MO AKO/PUSANG BASA

Records A data structure composed of a fixed number

of components of different types is usually termed a record.Int>>>>>>>>>>>Int>>>>>>>>>>>

Float>>>>>>>>>Char>>>>>>>>>

99312

Z

2901.10

27

Storage representation for Struct Employee

ID

AGE

SALARY

DEPT

Page 25: BANGUSIN MO AKO/PUSANG BASA

Implementation of vectors.The homogeneity of components and fixed size of vector make storage and accessing of individual components straightforward.

Packed and unpacked storage representation. A packed storage representation is one in which components of a vector are packed into storage sequentially without regard for placing a component at the beginning of an addressable word or byte of storage.

Page 26: BANGUSIN MO AKO/PUSANG BASA

Storage Implementation of records.

lvalue (R.I) = alpha + Ki when alpha is the base address and the Ki is the ith component.

struct EmployeeType{int ID

}

Page 27: BANGUSIN MO AKO/PUSANG BASA

(a b c)

LISTS A data structure composed of an ordered

sequence of data structure is usually termed as list.

list

atom a

list

list

atom Bb

atom c

Representation of storage for lists

Page 28: BANGUSIN MO AKO/PUSANG BASA

SETS A set is a data object containing an unordered

collection of distinct values. In contrast, a list is an ordered collection of values, some of which may be repeated.

In Programming Languages, the term set is sometimes applied to a data structure representing an ordered set. An ordered set is actually a list with duplicate values removed; it requires no special consideration. The unordered set, however, admits two specialized storage representations that merit attention.

Page 29: BANGUSIN MO AKO/PUSANG BASA

Bit-string representation of sets. The bit string storage representation is appropriate where the size of the underlying universe of values (the values that may appear in set data objects) is known to be small.Hash-coded representation of sets. A common alternative representation for a set is based on the technique of hash coding or scatter storage. This method may be used when the underlying universe of possible values is large (e.g., when the set contains numbers or character strings).

Page 30: BANGUSIN MO AKO/PUSANG BASA

Executable Data Objects in most languages, especially compiled languages

like C and Ada, executable source programs and the data objects they manipulate are separate structures. However, this is not necessarily always true. In languages like LISP and Prolog, executable statements may be data that are accessible by the program, and that may be manipulated by it. For example, LISP stores all of its data in lists. The scheme expression

(define myfunction(cons(a b c) (d e f)))Simply defines the function name myfunction to be the cons operation defined earlier. This is stored as a linked list much like any other list structures.

Page 31: BANGUSIN MO AKO/PUSANG BASA

Group : WANDEYSERBIS..Members

Daria, Daryll Louis Artificio, TimothyRagmac, ReinoelDe Asis, Joenel

Moron, John Meinard