You are on page 1of 4

Carlos Felipe R. Alvaro Dr.

Adoree Ramos
BSIT

2.1a What is the difference between a simple container and an associative container?
Answer:
- Simple Containers > Containers that store individual objects.
- Associative Containers > Containers that store keys but also store records associated
with those keys.
2.1b Is a dictionary a simple or associative container? Is the ordering a linear or a weak
ordering?
Answer:
- A dictionary is a associative container that is a linear ordering for it contains information
that is related to other different words and relations.
2.1c Is a phone book an example of a simple or associative container?
Answer:
- A phone books is a example of a simple container since it only stores individual phone
numbers without having any relations to other phone numbers.
2.1d A spell checker in a program such as a word processor keeps a list of recognized spellings
of known words. Is such a collection kept as a simple or associative container?
Answer:
- It is a simple container, it only checks the spellings of words that goes against its list of
spellings without any other process or any other relations.
2.1e What does it appear that the following function does?
Answer:
- It automatically pairs the list of names and birthdays with each other with the first pair
being the names listed in the program and the second pair are the birthdates.
Carlos Felipe R. Alvaro Dr. Adoree Ramos
BSIT

2.1f A hash table that stores associative array is sometimes described as a look-up table. For
example, in C++, the statement
#define MIN_VALUE -32
#define MAX_VALUE 31
Will change
For ( int I = MIN_VALUE; I <= MAX_VALUE; ++i) {
//…
}
to
for ( int I = -32; I <= 31; ++1) {
//…
}
Why would the preprocessor need a look up table to store such definitions?
Answer:
- It would save up time and CPU resources as it stores the values and calls them when
they are needed.

2.1g What are the six relationships we are considering in this class?
Answers:
- Linear orderings
- Hierarchical orderings
- Partial orderings
- Equivalence relations
- Weak orderings
- Adjacency relations
2.1h Is every linear ordering of a finite number of objects a hierarchical ordering? Is every
hierarchical ordering a partial ordering?
Answer:
- No, a linear ordering is a set of two relationship that can be compared with x < y, x = y
or y < x. While a hierarchical ordering is not the same as partial ordering as there are multiple
starting points and one class may have multiple prerequisites in a partial ordering.
Carlos Felipe R. Alvaro Dr. Adoree Ramos
BSIT

2.1i Specify which relationship most appropriately describes the following data sets:
1. The integers
2. Dictionary
3. The chain of command in the military
4. A sequences of tasks which must be completed, some of which must be completed
before others can be started
5. A road map
6. The relationship between the Object class of C# and Java subclasses
7. The real numbers
8. Courses and their prerequisites
9. A circuit layout
10. Main memory
11. Directories in a file system
12.The alphabet
13. The organization of a corporation
14. Phone book
15.The scope of variables in a function
Carlos Felipe R. Alvaro Dr. Adoree Ramos
BSIT

Answers:
1. Equivalence relations
2. Linear ordering
3. Hierarchical ordering
4. Partial ordering
5. Adjacency relations
6. Hierarchical ordering
7. Equivalence relations
8. Linear ordering
9. Partial ordering
10. Adjacency relations
11. Linear ordering
12. Linear ordering
13. Hierarchical ordering
14. Linear ordering
15. Partial ordering

You might also like