w1d5 Flashcards

1
Q

What is a tree comprised of?

A

Nodes

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

What is the top-level node called?

A

The root; it has children but no parents

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

What are bottom level nodes called?

A

The leaves; they have a parent but no children.

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

What is the maximum number of parents a node can have?

A

1

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

What is the difference between DFS and BFS?

A

Depth-first search uses a stack: Each node has its children pushed onto the stack, then each of those nodes has their children pushed on the stack. When a leaf is reached, the leaf is popped off the stack until a node with another child is found. A DFS algorithm is recursive.

BFS uses a queue; each node has its children added to the end of the queue, and nodes are shifted off the front of the queue and evaluated. A BFS algorithm utilized an iterative loop.

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