Data Structures and Abstract Data Types Flashcards

1
Q

What is the time complexity for hash table lookup?

A

O(1)

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

Name 2 collision resolution methods

A

Separate chaining (closed addressing), linear probing (open addressing)

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

What is the time complexity for linked list insertion and deletion? (Assuming the index for insertion/deletion is already known)

A

O(1)

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

What is the time complexity for linked list search?

A

O(n)

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

State three features of a good hashing algorithm

A
  1. The hash function uses all the input data
  2. The hash function uniformly distributes the data across the entire set of possible hash values
  3. The hash function generates very different hash values for similar (but non-identical) strings
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Name 2 Abstract Data Types.

A

Stack and Queue

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

How does a stack work?

A

Elements are pushed onto the stack, or popped from the stack.
The first element pushed onto the stack is the last element popped from the stack (FILO)

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

How does a queue work?

A

Elements are enqueued into the queue, or dequeued from the queue.
The first element enqueued is also the first element dequeued (FIFO)

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

What methods are required for a Queue ADT?

A

Enqueue: add an element to the queue
Dequeue: get the next element from the queue

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

What methods are required for a Stack ADT?

A

Push: add an element to the stack
Pop: get the next element from the stack

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

What are the key features of a Circular Queue?

A

Circular queues have a fixed capacity.
The last location in the array wraps around to the first location.

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

What does a hash function do in a hash table?

A

Hash function takes an input key and returns a location/index of fixed size. Each unique key hashes to the same location/index.

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