Chapter 6 Flashcards

1
Q

What does a data type define?

A

How an object is stored in memory.
Predefined operations on the object

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

What is the descriptor of a variable?

A

A collection of attributes of a variable

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

What are primitive data types?

A

Base line data types (not made up of other data types)

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

What data type is an exact reflection of the hardware?

A

Integer

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

What is a complex type?

A

(7 + 3j) 7 = real part, 3 = imaginary part

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

Adv + Con of decimals

A

Adv: accuracy
Cons: Waste memory + limited range

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

Why is an advantage of Booleans readability?

A

Reduced ambiguity ( true = yes, false = no )

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

What are characters stored as?

A

Numeric coding (ASCII)

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

Why is character string type evaluation a aid to writability?

A

Simplified operations. Directness + readability

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

Why is dynamic string length bad?

A

Cause it has additional cost ( memory overhead)

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

What is a User-defined ordinal type?

A

a enum. Only a finite number of possible values.

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

Why is enumerations good?

A

Aid to readability + reliability (only certain values are allowed)

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

What is the advantage + con of no index range checking in arrays?

A

Adv: performance

Con: Security (buffer overflow)

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

Why is static subscript binding good? ( Why is static arrays good)

A

Efficient execution

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

If subscript binding is static what type of binding must the storage binding be?

A

Also static ( length must be constant )

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

What is an advantage of a fixed stack-dynamic array?

A

Space efficiency

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

Why is space efficiency a advantage of fixed stack-dynamic arrays?

A

Memory is only allocated when called and released afterwards

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

Whats the biggest difference between stack dynamic and fixed stack dynamic?

A

Storage allocation ( fixed stack dynamic = constant length )

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

With stack dynamic arrays, is storage and subscript range statically bound or dynamically?

A

Dynamically because of variable length

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

When does subscript + storage binding become fixed with stack-dynamic arrays?

A

After initial binding

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

When does subscript + storage binding become fixed with fixed heap-dynamic arrays?

A

After allocation
int* p = new int[size]

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

Difference between fixed heap-dynamic arrays and heap-dynamic arrays?

A

Heap-dynamic can grow and shrink as items are added and removed

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

study differences between each languages array operations and if they increase or decrease read/write/reliability

24
Q

What is a jagged matrix?

A

Rows with various lengths

25
Which languages support both jagged and rectangular?
the sharps ( C# F# .... cause a jagged thing is sharp...)
26
What is a slice in data types?
Substructure of an array
27
What is an associative array?
Unordered collection of elements by keys ( hash map )
28
What is a record?
Like a row in a db
29
What is a nested record?
A record inside a record
30
Which language allows nested records?
COBOL + ada
31
Other languages use dot notation to specify a record. What does COBOL use?
OF Employee_record.Employee_name.Middle == MIDDLE OF EMPLOYEE-NAME OF EMPLOYEE-RECORD in COBOL
32
What does a elliptical reference mean?
Allow leaving out record names if reference is unambiguous
33
Which is slower? Array element access or record field access?
Array element access
34
When should you use records?
When data values arent the same type
35
What the difference between tuple types and records?
Tuple types are like records but elements arent named myTuple = (3, 5.8, "apple")
36
What is a list usually represented as?
As a linked list
37
What does mutable list mean?
You can add and remove elements without creating a new list
38
What is a union?
A type whose variable can store values of different types at different times
39
How many values can a union have at one time?
One
40
What does a discriminant do?
Check the type of a union
41
Whats the difference between Discriminated vs free unions?
Disciminated: has a discriminant ( type indicator) Free union doesnt
42
what is the discriminant here type Shape is (Circle, Triangle, Rectangle); type Colors is (Red, Green, Blue); type Figure (Form: Shape) is record Filled: Boolean; Color: Colors; case Form is when Circle => Diameter: Float; when Triangle => Leftside, Rightside: Integer; Angle: Float; when Rectangle => Side1, Side2: Integer; end case; end record;
Form
43
Why are free unions unsafe?
No type checking
44
What are 2 pointer uses?
Manage dynamic memory Use indirect addressing
45
What are the 2 fundamental operations for pointers?
Assignment + dereferencing
46
What is the problem with pointers?
Dangling pointers Lost heap-dynamic variable ( memory leaks )
47
What are reference types?
Similar to pointers but passes the actual memory location where the data is stored
48
Does java have reference variables?
Yes they replace pointers entirely
49
What is type checking?
Ensure operands of operators are compatible
50
What is the advantage of a strongly typed language?
Detects all variable misuses
51
What is coercion?
Convert operands to same type automatically ( a = float, b = int. a + b = change b to float then add )
52
Does coercion strengthen reliability?
No it weakens it
53
When are 2 types equivalent?
When the operands can be substitutable without coercion
54
What is Name type equivalence?
2 variables have the same types if both have the same declaration or *declarations have the same type name* typedef link struct * cell link next, last; struct * cell p; struct * cell q,r; Under name equivalence next and last is equivalent, and P + Q + R is equivalent
55
What is structure type equivalence?
When 2 variables have same types if their types have identical structures
56
What are the 2 branches of type theory?
Abstract and Practical
57
What is a type system?
A set of types