Data Structure - Tree Flashcards

1
Q

What is a tree?

A

It’s an abstract data type that represents a hierarchical tree structure with a set of connected nodes, where each node in the tree can be connected to many children, but must be connected to exactly one parent, except for the root node, which has no parent.

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

What is a binary tree?

A

It’s a tree with the constrain number of children for each parent to exactly two.

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

What are some applications of trees?

A

File systems, class hierarchy (inheritance), Abstract Syntax Trees and others.

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

What is tree transversal?

A

It’s the process of visiting and outputting the value of each node of a tree in a particular order.

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

How in-order transversal works?

A

It traverses from the left subtree, to the root then, to the right subtree

https://kalkicode.com/pixels/binary-tree/inorder-traversal-of-binary-tree.png

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

How pre-order transversal works?

A

It traverses from the root, to the left subtree then, to the right subtree.

https://kalkicode.com/pixels/binary-tree/preorder-tree-traversal.png

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

How post-order transversal works?

A

It traverses from the left subtree, to the right subtree, then to the root.

https://kalkicode.com/pixels/binary-tree/postorder-tree-traversal.png

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

Tree transversal exercise

A

https://media.geeksforgeeks.org/wp-content/cdn-uploads/Preorder-from-Inorder-and-Postorder-traversals.jpg

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