1 / 31

BANGUSIN MO AKO/PUSANG BASA

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.

cutler
Download Presentation

BANGUSIN MO AKO/PUSANG BASA

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. PROGRAMMING LANGUAGEBSCS-2CProf. Mina Villafuerte

  3. 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).

  4. 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, tablesand filesare examples of variable-size types.

  5. Type of each components. A data structure is homogeneous if all its components are of the same type. It is heterogeneousif 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.

  6. Maximum number of components. FOR A VARIABLE SIZE DATA STRUCTURES SUCH A STACKS. Organization of the component.Themost 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

  7. Operations on Data Structures Specification 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

  8. 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).

  9. 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 Types Implementation 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

  10. 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. :

  11. Component Component Component Component Component Component Component Sequential Linked Component Component

  12. 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.

  13. 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.

  14. 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.

  15. Storage Management and Data Structures The 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 pathto the data must also be created so that the data object can be accessed by operations in the program.

  16. 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.

  17. Base address = Location of A[0] A[0] A[1] Offset = i x component size = 5 x 1 = 5 A[5] Accessing components in a C char array Base address + offset = lvalue(A[0]) + 5 = lvalue(A[5])

  18. 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 referenceis 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).

  19. 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:

  20. 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 Arrays A vector is a data structure composed of a fixed number of components of the same type organized as a simple linear sequence.

  21. 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.

  22. Base Address of Vector Vector Data type LB Lower subscript bound UB Upper subscript bound Descriptor (dope vector) Integer Data type of component E Size of component A[LB] A[LB+1] Storage representation For components A[UB]

  23. 39 27 15 42 1 2 3 1 2 3 1 2 3 30 18 4 5 6 4 5 6 4 5 6 45 33 21 48 7 8 9 7 8 9 7 8 9 36 24 10 11 12 10 11 12 10 11 12 Column Slice Row Slice Multidimensional Slice

  24. 99312 ID 27 AGE Records A data structure composed of a fixed number of components of different types is usually termed a record. Int>>>>>>>>>>> Int>>>>>>>>>>> Float>>>>>>>>> Char>>>>>>>>> 2901.10 SALARY Z DEPT Storage representation for Struct Employee

  25. 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.

  26. Storage Implementation of records. lvalue (R.I) = alpha + Ki when alpha is the base address and the Ki is the ith component. structEmployeeType{ int ID }

  27. (a b c) list atom a list LISTS A data structure composed of an ordered sequence of data structure is usually termed as list. atom Bb list atom c Representation of storage for lists

  28. 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.

  29. 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).

  30. 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.

  31. Group : WANDEYSERBIS.. Members Daria, Daryll Louis Artificio, Timothy Ragmac, Reinoel De Asis, Joenel Moron, John Meinard

More Related