Module 3 - Data Types, Expression and Assignment Statements Flashcards

1
Q

The basic concept of the representation of data in programming languages

A

Data type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Data in its most primitive form

A

A collection of ones and zeros (bits)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Are often part of the application of data concepts

A

Machine dependencies

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Concept of data limits

A

In math, the set of integer values are infinite. In hardware, there will always be a largest and smallest number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Program data can be classified according to?

A

Their types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Represents the possible values that a variable of that type can hold and the way those values are represented internally

A

Type name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Definition 1: A set of values the statement int x; is the same as x ∈ Integers

Definition 2): a set of values, together with a set of operations on that values having certain properties

Part of mathematical algebra

A class of data objects with a set of operations for creating and manipulating them.

A

Data type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Specification of data types

A

Attributes
Values
Operations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A data type specification that classify data objects of a given type by Data type and name – does not vary during the lifetime of the object

These can be stored in a descriptor and utilized during the program execution

These are only utilized to establish the storage representation, not used explicitly during execution

A

Attributes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

A data type specification that defines the values that a data object of that type could get

Typically, they can be a well-ordered set, i.e. it has a least and a greatest value

A

Values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

A data type specification that define the potential manipulations of data objects of that type.

A

Operations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Operations that are denoted as part of data objects of that type

A

Primitive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Operations that can be represented as subprograms, or class methods

A

Programmer-defined

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

An Operation is defined by:

A

Domain - set of probable input arguments
Range - set of potential results
Action - how the result is generated

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Specifies the domain and the range

A

Operation signature

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Source of ambiguity in operations

A

Undefined operations for some inputs.

Implicit arguments, e.g. use of global variables

Implicit results - the operation may alter its arguments

Self-modification - typically through change of local data among calls, e.g. random number generators change the seed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Storage Representation is influenced by the hardware described in terms of:

A
  1. Size of the memory blocks required
  2. Layout of attributes and data values within the block
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

In storage representation, methods to treat attributes

A
  1. established by the compiler and not stored in descriptors during execution - C
  2. stored in a descriptor as component of the data object at run time - LISP Prolog
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Implementation of operations

A
  1. Hardware operation - direct implementation (E.g. Integer addition)
  2. Subprogram/function, e.g. square root operation
  3. In-line code - code is copied into the program at the point where the subprogram would have been invoked.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Elementary Data Types

A

Scalar Data Type
Composite Data Types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Data types that represent a single object, i.e. only one value can be derived.

In general, these type of objects follow the hardware architecture of a computer.

A

Scalar Data Types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Numerical Scalar Data Types

A

Integers
Sub-ranges
Floating-point real numbers
Fixed-point real numbers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Specification: Maximal and minimal values

Operations:
Arithmetic
Relational
Assignment
Bit operations

Implementation: hardware defined

A

Integers Scalar Data Type

24
Q

A scalar data type that is a series of integer values inside some controlled range

Ex: Pascal declaration A: 1..10 means that the variable A may be assigned integer values from 1 through 10.

Specification: subtype of integer

Implementation: smaller storage requirements, better type checking

A

Sub-ranges Scalar Data Type

25
Specification: Minimum and maximal value Round-off issues - the check for equality may fail due to round -off Implementation: Mantissa - exponent model. Ex: 10.5 = 0.105 x 102, Mantissa: 105, Exponent: 2
Floating-point real numbers Scalar Data Types
26
Specification: real numbers with predefined decimal places Implementation : directly supported by hardware or simulated by software
Fixed-point real numbers
27
Other Scalar Data Types
Complex Numbers Rational Numbers Enumerations Booleans Characters
28
A Scalar data type that are software simulated, with two storage locations one the real portion and one for the imaginary portion.
Complex numbers
29
A Scalar data type that can be defined easily as the quotient of two integers, in other terms fractions.
Rational numbers
30
Implementation: represented during run time as integers, corresponding to the listed values. Ex: enum StudentClass {Fresh, Soph, Junior, Senior} the variable StudentClass may accept only one of the four listed values.
Enumerations
31
Specification: Two values: true and false. Can be given explicitly as enumeration Basic operations: and, or, not. Implementation: A single addressable unit such as byte or word. Use a bit for the value, e.g. the last bit; 1 - true, 0 -false. Use the entire storage; a zero value would then be false, otherwise - true.
Booleans
32
Specification: Single character as a value of a data object. Collating sequence - the ordering of the characters, used for lexicographic sorting. Operations: Relational, Assignment, Testing the type of the character - e.g. digit, letter, special symbol. Implementation: supported by the underlying hardware
Characters
33
Data types that are characterized by a complex data structure organization, processed by the compiler.
Composite Data Types
34
Composite Data Types
Character Strings Pointers and Programmer - Constructed Objects Files
35
Specification: Fixed declared length: storage allocation at translation time. Strings which are longer than the declared length are truncated. Variable length to a declared bound: storage allocation at translation time. An upper bound for length is set and any string over that length is truncated Unbounded length: storage allocation at run time. String can be any length Implementations: Fixed declared length: A packed vector of characters Variable length to a declared bound: a descriptor that contains the maximum length and the current length Unbounded length: Either a linked storage of fixed-length data objects or a contiguous array of characters with dynamic run-time storage allocation
Character Strings Composite Data Type
36
Character Strings Composite Data Type Operations
Concatenation – appending two strings Relational operations – equal, less than, greater than Substring selection using positioning subscripts Substring selection using pattern matching Input / output formatting
37
Specification: Reference data objects only of a single type – C, Pascal, Ada. Reference data objects of any type – Smalltalk C, C++: pointers are data objects and can be manipulated by the program Java: pointers are hidden data structures, managed by the language implementation Implementations: Absolute addresses stored in the pointer. Enables storing the new object anywhere in the memory Relative addresses: offset with respect to some base address.
Pointers and Programmer-Constructed Objects
38
Usually reside on secondary storage devices as disks, tapes. Life Cycle is greater than the duration of the program that has created the files. Implementation – as part of the operating system
Files
39
Types of Files
1. Sequential file 2. Interactive Input-Output 3. Direct Access Files 4. Indexed Sequential Files
40
Type of file that is a data structure composed of a linear sequence of components of the same type.
Sequential file
41
Type of file that are sequential files used in interactive mode.
Interactive Input-Output
42
Type of file that is any single component can be accessed at random just as in an array. Implementation: a key table is kept in main memory
Direct Access Files
43
In Direct Access Files, it is the subscript to access a component.
Key
44
Type of file like direct access files, it uses a key combined with being able to sequentially process the file. The file must be ordered by the key
Indexed Sequential Files
45
A data object that contains other data objects as its elements or components.
Data structure
46
Mechanisms to create new data types:
Structured data Subprograms Type declarations – to define new types and operations (Abstract data types) Inheritance
47
Types of Structured data
Homogeneous: arrays, lists, sets. Non-homogeneous: records
48
Data specifications
Number of components and size Type of each component Selection mechanism - to identify components - index, pointer Maximum number of components Organization of the components
49
Number of components and size
Fixed size – Arrays Variable size – stacks, lists. Pointer is used to link components.
50
Type of each component
Homogeneous – all components are the same type Heterogeneous – components are of different types
51
Selection mechanism two-step process
1. Referencing the structure 2. Selection of a specific component
52
Organization of the components
Simple linear sequence - arrays, stacks, lists Multidimensional structures: separate types (Fortran) A vector of vectors (C++)
53
Operations on data structures
Component selection operations Insertion/deletion of components Whole-data structure operations
54
Component selection operations types in Operations on data structures
Sequential Random
55
The whole-data structure operations in operations on data structures
Creation/destruction of data structures
56