Sets and Maps

16 flashcardsby Maria
Study these flashcardsFree · spaced repetition · iPhone, Android, Mac & web

All cards

1
What is the advantage of storing data in binary format?
Records are the all the same size so they are easy to access randomly, and update.
2
What are the two basic ways to represent a set?
explicitly - uses a bit vector
implicitly - uses List, usually sorted List to improve Big O notation
3
What does it mean to "serialize" an object.
Professor answer: Copy an object to an output stream in a way that when deserialized it maintains its structure, i.e. a binary tree.
Better answer lol To serialize an object means to convert it into a flat, transferable format that captures its data and structure, allowing it to be saved or sent elsewhere and then reconstructed back into an object. This is essential for persistence, data sharing, and communication between systems.
4
The mathematical definition of a set is that is has no particular order. However when we use HashSet or TreeSet there is certain ordering given to the elements of the set because of the basic data structure that they are stored in. What is the difference between the "order" for a HashSet and a TreeSet.
A HashSet is ordered by the hashcode. A TreeSet is ordered by the natural ordering of the objects being placed in to the Set.
5
What is a map?
A mapping from the key set to the value set. It associates a key to a value.
6
What are the two ways data can be stored?
1) Key
2) Binary
7
Every [A] in a map has a unique value.
Key
8
Random access files use a [A] to determine the location in the file to read from or write to.
File pointer
9
A [A] in a map can be associated with several keys.
Value
10
ObjectInputStream and ObjectOutputStream can only read/write objects that support the [A] interface.
Serializable
11
What is the difference between a set and a map?
A set stores unique elements. A map stores associations between keys and values.
12
What are the basic operations that are unique to a Set?
[A] union
[B] intersection
[C] difference
13
How would 12,345 be represented in:
text format [A]
binary format[B]
Text Format: stored as characters
'1' '2' '3' '4' '5'
Binary Format: stored as 4 bytes
0 0 48 57
14
Classes that implement Serializable but require special handling during the serialization and deserialization process must give definitions for which methods:
[A] readObject
[B] writeObject
15
What are the two most common Java library classes that implement the Set interface?
[A] HashSet
[B] TreeSet
16
What does it mean to "serialize" an object?
Copy an object to an output stream in a way that when deserialized it maintains its structure, i.e. a binary tree.
Study all 16 cards for free