Quiz 1 Flashcards

1
Q

What is a heap?

A

A heap is a tree-like data structure. It is
often used to implement the ADT priority
queue.

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

What is a binary heap?

A

A binary heap is a nearly complete binary
tree filled on all levels except possibly the
lowest level where leaves (values) are
pushed left-most.

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

How are heaps usually implemented?

A

Heaps are usually implemented as an array.

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

What does each node of a heap satisfy?

A

The heap property

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

What is a max heap?

A

Every node’s value is larger than (or equal to) the values of its children.

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

What is a min heap?

A

Every node’s value is less than (or equal to) the value of its children.

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

What is a priority queue?

A

A priority queue is an ADT which has methods for inserting an item and removing the smallest (or largest) item.

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

True or False: A priority queue can be implemented in several ways – a heap being one – but a heap is a more fundamental data structure.

A

True

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

Regarding min heap methods, what is the space-time complexity of Min(h)?

A

O(1)

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

Regarding min heap methods, what is the space-time complexity of Insert(H, k)?

A

O(log(n))

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

Regarding min heap methods, what is the space-time complexity of DeleteMin(H)?

A

O(log(n))

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

What min heap method removes the root, places the right-most leaf into the root position and moves down the node until the heap property is satisfied?

A

DeleteMin(h)

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

An array A that represents a heap is an object with what two attributes?

A

A.length, A.heap-size

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

Regarding a heap, what is the space-time complexity of determining a position?

A

O(1)

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

The heap property is what allows operations to be performed quickly. What is the heap property?

A

The minimum (or maximum) should be the root, and any node should be smaller (or larger) than its descendants.

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

What is a heap called where 𝐴[Parent(𝑖)] ≥ 𝐴[𝑖]

A

Max-heap

17
Q

What is a heap called where 𝐴[Parent(𝑖)] ≤ 𝐴[𝑖]

A

Min-heap