Data Structures Flashcards

1
Q

What is a graph

A

Any collection of nodes and their pointers to other nodes. Linked lists and trees are both types of graphs

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

What is a binary tree

A

A binary tree is a type of tree. It is a collection of nodes. Every node has between 0 to 2 children, and every node except the root has exactly one parent.

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

In a tree, what is a root node

A

The root node is the node at the “top” of the tree. Every node in the tree is accessible starting from the root node. The root node has no parents

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

In a tree, what is a parent and what is a child

A

If you have a node A with an edge to a node B, so A -> B, we call A the parent of node B, and node B a child of node A.

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

In a tree, what is a leaf node

A

A leaf node is a node that has no children

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

In a tree, what is the depth of a node

A

The depth of a node is how far it is from the root node. The root has a depth of 0. Every child has a depth of parentsDepth + 1, so the root’s children have a depth of 1, their children have a depth of 2, and so on.

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

in a tree, what is a subtree

A

A subtree of a tree is a node and all of it’s descendants. A subtree is a valid tree where the chose node is the root of the subtree

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