Data Structures Flashcards

1
Q

What are the functions of a Hash Table?

A

Search, Insert, Delete

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

What are the running times of Hash Table functions?

A

Search O(1). Insert O(1). Delete O(1).

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

Why is it called a hash table?

A

A hash function is used on key k to compute the destination slot.

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

What is the linked-list collisions resolution called?

A

Chaining

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

What are the differences between an ArrayList and a Vector?

A

An ArrayList is not thread-safe, while the Vector is. However, this means that the ArrayList may be a faster data structure. The ArrayList doubles in size when mas size is reached, which means it grows exponentially. The Vector grows by a specified, constant size.

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

What is the running time for an ArrayList?

A

The ArrayList provides constant time access O(1), amortized over time. The reason being that it is doubled every time space runs out. Therefore the frequency of resizing drops substantially.

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

When might you want to use StringBuffer?

A

When you plan on doing an operation that will require making many copies of a string. Such as repeated concatenation to the end of the same string. Since Java strings are immutable, the string would have to be copied for every concatenation

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