Tree Traversal Flashcards

1
Q

What are the methods of tree traversal?

A

Inorder, preorder, postorder, and level traversal.

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

What is inorder traversal?

A

left, node, right.

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

What is preorder traversal?

A

node, left, right.

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

What is postorder traversal?

A

left, right, node.

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

When to use BFS vs DFS?

A

Use BFS when finding the shortest path in unweighted graphs or level-order traversal.

Use DFS when exploring all possible paths (e.g., backtracking problems, cycle detection).

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

What is a binary search tree?

A
  • Standard BSTs have no duplicate values.
  • left sub tree must have values less than parent node
  • right sub tree must have values greater than parent node.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the search time complexity of balanced vs unbalanced trees?

A

o(log n) for balanced
and o (n) for unbalanced (like linked list)

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