Data structures Flashcards

1
Q

Implementation of Breadth First Search uses what?

A

Queue - add child nodes . shift off node from front.

repeat until queue is empty

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

Implementation of Depth First Search uses?

A

Stack - add nodes. remove end nodes from end.

Often recursion.

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

what is a heap? (2 types)

A

binary tree where children are smaller (max heap) or larger (min heap) than parent. Root node is smallest (min heap) or largest (max heap)

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

what is heapifying?

A

looping through heap and swapping up/down nodes depending on min/max

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

insert into heap?

A

add as leaf node, then heapify

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

heap sort?

A

1 - build a heap from unsorted array
2 - take root node and swap with last element, then remove that last element to ‘sorted’ array
3 - re-heapify the heap
4 - repeat

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

index of heap last parent node in an array

A

array.length (rounded down) - 1

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