Shared Flashcard Set

Details

CMSC 403: Programming Languages (Quiz 2)
N/A
27
Computer Science
Undergraduate 4
09/08/2011

Additional Computer Science Flashcards

 


 

Cards

Term
What is a value?
Definition
any entity that exists during computation
Term
Why can't all values be stored?
Definition
space limitations in memory
Term
What is a type?
Definition
a classification for identifying data
Term
What are the 3 kinds of types?
Definition
primitive, composite, recursive
Term
How can one represent composite types in Java?
Definition
an array
Term
What is a primitive type?
Definition
one whose values are atomic and therefore
cannot be decomposed into simpler values
Term
How and why do values of primitive types vary from one machine to another?
Definition
different word sizes in different machines, instruction set
Term
What is an enumerated type?
Definition
a user-defined (usually ordinal) primitive
type where all possible values have been provided (or enumerated)
Term
What is an ordinal type?
Definition
a type where all possible values (except the
first and last ones) have a unique predecessor and successor
Term
What primitive types found in most languages are not also ordinal types? Why?
Definition
Real values, because there are infinite # of them and cant be enumerated
Term
What is the cardinality of a type?
Definition
the number of distinct or
unique values in the set
Term
What is a composite type?
Definition
a type whose values are composed or structured from simpler values
Term
What is a cartesian product type?
Definition
the pairing of two (or more) (possibly
different) values where the order is significant
Term
How would we define (formally and in Pascal) the type of an individual entry (value)
in a phone book consisting of a first name, last name, and a phone number? What is this new type's cardinality?
Definition
Cartisian Product
String x String x Integer
Term
How does one implement a cartesian product type in Java?
Definition
a method with instance variables
Term
What are homogeneous tuples? 0-tuples?
Definition
all tuple components are chosen from
the same set

homogeneous tuple with no components
Term
What is a disjoint union type?
Definition
value is chosen from either of two (or
more) (usually different) types
Term
What are tags in disjoint union types?
Definition
considered part of a disjoint union value
Term
How would we define (formally and in Pascal) a disjoint union type with 3 fields
of type integer, real, and string? What is the cardinality of this new type?
Definition
Integer + Real + String
#Integer + #Real + #String
Term
What is the problem with how disjoint unions types are implemented in Pascal?
Definition
tags are essentially ignored in pascal so it doesnt do the proper checking
Term
Is a disjoint union the same thing as set union? Why or why not?
Definition
no because there are tags associated with both the values that are linked by the disjoint union
Term
What is a mapping type?
Definition
a mathematical relation such that each element of a
given set (type) is associated with an element of another set
Term
What are the operations for mapping types?
Definition
for arrays: indexing
for functions abstractions: calling the function
Term
What are the two types of mappings and how are they implemented in programming languages?
Definition
Finite mappings using arrays
non finite mappings using function abstractions
Term
How would we define (formally and in Pascal) a mapping type that maps integers to strings? What is the cardinality of this new type?
Definition
Integer --> String
#Integer --> #String
Term
Are functions in Pascal the same thing as mathematical functions? Why or why not?
Definition
no, because since the state of global variables can be updated in pascal, a function given the same parameter value may not return the same answer
Term
How would the mapping (Integer X Real X String) --> Truth-Value be implemented in Pascal?
Definition
function add (x:integer; y:string; z:real):boolean;
Supporting users have an ad free experience!