What is the order of visiting nodes in pre-order traversal?
Analysis & Theory
Pre-order traversal visits nodes in the order: Root, then Left subtree, then Right subtree.
Which traversal is most suitable for creating a copy of a binary tree?
Analysis & Theory
Pre-order traversal is used to create a copy of a binary tree as it visits the node before its children.
Given this binary tree:
A
/ \
B C
/ \ \
D E F
What is its pre-order traversal?
Analysis & Theory
Pre-order: Root A, Left B, B's Left D, B's Right E, Right C, C's Right F.
Which data structure is typically used to implement iterative pre-order traversal?
Analysis & Theory
A stack is used to simulate recursion and manage nodes to be visited next.
In pre-order traversal, when is the root node visited?
A
After visiting the left and right subtrees
B
Before visiting any subtrees
C
After visiting the left subtree only
D
After visiting the right subtree only
Analysis & Theory
In pre-order traversal, the root is always visited first.
Which traversal is used for expression tree prefix notation?
Analysis & Theory
Pre-order traversal gives prefix notation for expression trees.
How many times does a pre-order traversal visit each node?
Analysis & Theory
Every node is visited exactly once in pre-order traversal.
Which of the following statements is TRUE about pre-order traversal?
A
It always processes leaves before internal nodes
B
It is the same as in-order traversal for all trees
C
It processes the parent node before its children
D
It requires a queue instead of a stack
Analysis & Theory
In pre-order traversal, the parent is processed before its children.
What is the time complexity of pre-order traversal in a binary tree with n nodes?
Analysis & Theory
Every node is visited exactly once, resulting in O(n) time complexity.
Which traversal is most appropriate for serializing a tree structure?
Analysis & Theory
Pre-order traversal is often used to serialize a tree because it records the root before its subtrees.